Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: WinAPI tooltip shows, then hides and then shows again


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 0
Igor Marchenko

Posts: 43
Registered: 4/1/11
WinAPI tooltip shows, then hides and then shows again  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 29, 2014 11:38 PM
I use the following code for adding tooltip to selected window region (RECT):
 INITCOMMONCONTROLSEX icc;
InitCommonControlsEx(&icc);
icc.dwSize = sizeof(INITCOMMONCONTROLSEX);
icc.dwICC = ICC_BAR_CLASSES;
 
HWND tooltip_hwnd = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, "MyTooltip", WS_POPUP | TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT, hwnd, NULL, (HINSTANCE)GetModuleHandle(NULL), NULL);
 
SetWindowPos(tooltip_hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE |WP_NOACTIVATE);
 
SendMessage(tooltip_hwnd, TTM_SETMAXTIPWIDTH, 0, 200);
SendMessage(tooltip_hwnd, TTM_SETDELAYTIME, TTDT_AUTOPOP, 15000);
SendMessage(tooltip_hwnd, TTM_SETDELAYTIME, TTDT_RESHOW, 10);
 
TOOLINFO ti = {0};
ti.cbSize = sizeof(TOOLINFO);
ti.uFlags = TTF_SUBCLASS;
ti.hwnd = hwnd;
ti.hinst = (HINSTANCE)GetModuleHandle(NULL);
ti.uId = 1;
ti.lpszText = "tooltip_text";
ti.rect.left = 10;
ti.rect.top = 10;
ti.rect.right = 100;
ti.rect.bottom = 80;
SendMessage(tooltip_hwnd, TTM_ADDTOOL, 0, (LPARAM)(LPTOOLINFO)&ti);

And problem is in here: when the mouse cursor appears above the selected rect, then tooltip window quickly shows, then hides and then shows again. Where is mistake in this code? And how to fix this bug?
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02