Displaying a ToolTip
-
Hi everyone, I'm trying to add a tooltip to my buttons on a toolbar,but without any luck.I checked it out with spy++ and HWND seems valid,but i can't activate the tool tip.According to documentation stuff,I do not have to write a message handler for my tooltips to be displayed (I use the TTF_SUBCLASS flag),am I wrong,or missing something in the code below?
RECT rect; HWND hwndTT; INITCOMMONCONTROLSEX iccex; ATLVERIFY((SendMessage(hwndParent,TB_GETITEMRECT,(WPARAM) iButton,(LPARAM) (LPRECT)&rect)) == TRUE); // get button rectangle,working OK. iccex.dwICC = ICC_WIN95_CLASSES; iccex.dwSize = sizeof(INITCOMMONCONTROLSEX); InitCommonControlsEx(&iccex); if ((hwndTT = CreateWindowEx( WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwndParent, NULL, NULL, NULL )) == NULL) return NULL; ::SetWindowPos(hwndTT,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); TOOLINFO ti; ti.cbSize = sizeof(TOOLINFO); ti.uFlags = TTF_SUBCLASS; ti.hwnd = hwndParent; ti.lpszText = (LPTSTR) lpszText; ti.rect.bottom = rect.bottom; ti.rect.left = rect.left; ti.rect.top = rect.top; ti.rect.right = rect.right; SendMessage(hwndTT,TTM_SETDELAYTIME,TTDT_INITIAL,0L); return SendMessage(hwndTT,TTM_ADDTOOL,0,(LPARAM)&ti);
-
Hi everyone, I'm trying to add a tooltip to my buttons on a toolbar,but without any luck.I checked it out with spy++ and HWND seems valid,but i can't activate the tool tip.According to documentation stuff,I do not have to write a message handler for my tooltips to be displayed (I use the TTF_SUBCLASS flag),am I wrong,or missing something in the code below?
RECT rect; HWND hwndTT; INITCOMMONCONTROLSEX iccex; ATLVERIFY((SendMessage(hwndParent,TB_GETITEMRECT,(WPARAM) iButton,(LPARAM) (LPRECT)&rect)) == TRUE); // get button rectangle,working OK. iccex.dwICC = ICC_WIN95_CLASSES; iccex.dwSize = sizeof(INITCOMMONCONTROLSEX); InitCommonControlsEx(&iccex); if ((hwndTT = CreateWindowEx( WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwndParent, NULL, NULL, NULL )) == NULL) return NULL; ::SetWindowPos(hwndTT,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); TOOLINFO ti; ti.cbSize = sizeof(TOOLINFO); ti.uFlags = TTF_SUBCLASS; ti.hwnd = hwndParent; ti.lpszText = (LPTSTR) lpszText; ti.rect.bottom = rect.bottom; ti.rect.left = rect.left; ti.rect.top = rect.top; ti.rect.right = rect.right; SendMessage(hwndTT,TTM_SETDELAYTIME,TTDT_INITIAL,0L); return SendMessage(hwndTT,TTM_ADDTOOL,0,(LPARAM)&ti);
please when posting a piece of code, to use the
<pre>
tag instead of the<code>
one. thanks
Don't know where to start ?
Refer the Forums Guidelines and ask a friend -
Hi everyone, I'm trying to add a tooltip to my buttons on a toolbar,but without any luck.I checked it out with spy++ and HWND seems valid,but i can't activate the tool tip.According to documentation stuff,I do not have to write a message handler for my tooltips to be displayed (I use the TTF_SUBCLASS flag),am I wrong,or missing something in the code below?
RECT rect; HWND hwndTT; INITCOMMONCONTROLSEX iccex; ATLVERIFY((SendMessage(hwndParent,TB_GETITEMRECT,(WPARAM) iButton,(LPARAM) (LPRECT)&rect)) == TRUE); // get button rectangle,working OK. iccex.dwICC = ICC_WIN95_CLASSES; iccex.dwSize = sizeof(INITCOMMONCONTROLSEX); InitCommonControlsEx(&iccex); if ((hwndTT = CreateWindowEx( WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwndParent, NULL, NULL, NULL )) == NULL) return NULL; ::SetWindowPos(hwndTT,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); TOOLINFO ti; ti.cbSize = sizeof(TOOLINFO); ti.uFlags = TTF_SUBCLASS; ti.hwnd = hwndParent; ti.lpszText = (LPTSTR) lpszText; ti.rect.bottom = rect.bottom; ti.rect.left = rect.left; ti.rect.top = rect.top; ti.rect.right = rect.right; SendMessage(hwndTT,TTM_SETDELAYTIME,TTDT_INITIAL,0L); return SendMessage(hwndTT,TTM_ADDTOOL,0,(LPARAM)&ti);
ajitatif angajetor wrote:
SendMessage(hwndTT,TTM_SETDELAYTIME,TTDT_INITIAL,0L);
You have passed delay time value(LPARAM) as 0. Is it intentional ? For setting default delay it should be -1.
Prasad Notifier using ATL | Operator new[],delete[][^]
-
ajitatif angajetor wrote:
SendMessage(hwndTT,TTM_SETDELAYTIME,TTDT_INITIAL,0L);
You have passed delay time value(LPARAM) as 0. Is it intentional ? For setting default delay it should be -1.
Prasad Notifier using ATL | Operator new[],delete[][^]
prasad_som wrote:
You have passed delay time value(LPARAM) as 0. Is it intentional ?
Yes,to pop the ToolTip up instantly,so I can see the rectangle is exactly as I meant it to be.
-
prasad_som wrote:
You have passed delay time value(LPARAM) as 0. Is it intentional ?
Yes,to pop the ToolTip up instantly,so I can see the rectangle is exactly as I meant it to be.
Code is looking ok to me. Can you show how you have created toolbar ?
Prasad Notifier using ATL | Operator new[],delete[][^]
-
Code is looking ok to me. Can you show how you have created toolbar ?
Prasad Notifier using ATL | Operator new[],delete[][^]
uh,i had to hack my code much more throughly to see it was all about rectangles.i found out that the toolbar had one of the items resized after i created the tooltip (with the wrong rectangles). and i added a
TB_SETTOOLTIPS
message right after theTTM_ADDTOOL
.works just fine now,thanks for everything :)