Discussion:
Tooltip doesn't get visible
(too old to reply)
unknown
2007-09-13 12:55:46 UTC
Permalink
Hello!

I create a tooltip-window with the following lines of code:

// create ToolTip-Control
hwndTT = ::CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, TOOLTIPS_CLASS,
NULL, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwndListBox,
NULL, NULL, NULL);
if (__information->ToolTip == NULL)
(
return FALSE;
}
::SetWindowPos(__information->ToolTip, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE
| WP_NOSIZE | SWP_NOACTIVATE);

// configure ToolTip-Control
TOOLINFO ttInfo;
::ZeroMemoryttInfo, sizeof(ttInfo));
ttInfo.cbSize = sizeof(ttInfo);
ttInfo.uFlags = TTF_TRACK | TTF_TRANSPARENT | TTF_ABSOLUTE;
ttInfo.hwnd = hwndListBox;
::SendMessage(hwndTT , TTM_SETMAXTIPWIDTH, 0, SHRT_MAX);
::SendMessage(hwndTT , TTM_ADDTOOL, 0, (LPARAM)(LPTOOLINFO)&ttInfo);
::SendMessage(hwndTT , TTM_SETTIPBKCOLOR,
(WPARAM)::GetSysColor(COLOR_HIGHLIGHT), 0);
::SendMessage(hwndTT , TTM_SETTIPTEXTCOLOR,
(WPARAM)::GetSysColorCOLOR_HIGHLIGHTTEXT), 0);

RECT __tooltiprect;
__tooltiprect.left = 0;
__tooltiprect.top = -1;
__tooltiprect.right = 0;
__tooltiprect.bottom = -1;
::SendMessage(hwndTT, TTM_SETMARGIN, 0, (LPARAM)&__tooltiprect);

HFONT __tooltipfont = (HFONT)::SendMessage(hwndListBox, WM_GETFONT, 0, 0);
::SendMessage(hwndTT, WM_SETFONT, (WPARAM)__tooltipfont, FALSE);

LONG lStyle = ::GetWindowLong(hwndTT, GWL_STYLE);
lStyle &= ~WS_BORDER;
::SetWindowLong(hwndTT, GWL_STYLE, lStyle);


As you might see, the tooltip is created as child of a listbox control.
Later I subclass the listbox control performing hittesting of mousemoves
determinig if the mouse is positioned over any listbox-item which is longer
than the listbox itself.
If this happens, I'd like to show the tooltip to display the whole text.
To show the tooltip, I call the following messages:

::SendMessage(hwndTT, TTM_UPDATETIPTEXT, 0, (LPARAM)&ttInfo);
::SendMessage(hwndTT, TTM_TRACKPOSITION, 0,
(LPARAM)MAKELONG(listboxitemrect.left, listboxitemrect.top));
::SendMessage(hwndTT, TTM_TRACKACTIVATE, TRUE, (LPARAM)(LPTOOLINFO)&ttInfo);

The problem is, that the complete thing works, no errors, listbox-item-size
determined correctly, tooltip-position determined correctly, BUT no tooltip
is shown.
And now the strange thing. If I just create a manifest-file for my
application, the tooltip gets shown.

Has anyone of you an idea, whats missing, to show the tooltip without a
manifest?

Thanks in advance!
Max
Christian ASTOR
2007-09-13 14:22:40 UTC
Permalink
Post by unknown
The problem is, that the complete thing works, no errors, listbox-item-size
determined correctly, tooltip-position determined correctly, BUT no tooltip
is shown.
And now the strange thing. If I just create a manifest-file for my
application, the tooltip gets shown.
If I do about the same thing, I haven't this problem.
(differences : InitCommonControls() before, ttInfo.uId correctly filled)
Kellie Fitton
2007-09-13 14:54:18 UTC
Permalink
Post by unknown
Hello!
// create ToolTip-Control
hwndTT = ::CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, TOOLTIPS_CLASS,
NULL, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwndListBox,
NULL, NULL, NULL);
if (__information->ToolTip == NULL)
(
return FALSE;}
::SetWindowPos(__information->ToolTip, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE
| WP_NOSIZE | SWP_NOACTIVATE);
// configure ToolTip-Control
TOOLINFO ttInfo;
::ZeroMemoryttInfo, sizeof(ttInfo));
ttInfo.cbSize = sizeof(ttInfo);
ttInfo.uFlags = TTF_TRACK | TTF_TRANSPARENT | TTF_ABSOLUTE;
ttInfo.hwnd = hwndListBox;
::SendMessage(hwndTT , TTM_SETMAXTIPWIDTH, 0, SHRT_MAX);
::SendMessage(hwndTT , TTM_ADDTOOL, 0, (LPARAM)(LPTOOLINFO)&ttInfo);
::SendMessage(hwndTT , TTM_SETTIPBKCOLOR,
(WPARAM)::GetSysColor(COLOR_HIGHLIGHT), 0);
::SendMessage(hwndTT , TTM_SETTIPTEXTCOLOR,
(WPARAM)::GetSysColorCOLOR_HIGHLIGHTTEXT), 0);
RECT __tooltiprect;
__tooltiprect.left = 0;
__tooltiprect.top = -1;
__tooltiprect.right = 0;
__tooltiprect.bottom = -1;
::SendMessage(hwndTT, TTM_SETMARGIN, 0, (LPARAM)&__tooltiprect);
HFONT __tooltipfont = (HFONT)::SendMessage(hwndListBox, WM_GETFONT, 0, 0);
::SendMessage(hwndTT, WM_SETFONT, (WPARAM)__tooltipfont, FALSE);
LONG lStyle = ::GetWindowLong(hwndTT, GWL_STYLE);
lStyle &= ~WS_BORDER;
::SetWindowLong(hwndTT, GWL_STYLE, lStyle);
As you might see, the tooltip is created as child of a listbox control.
Later I subclass the listbox control performing hittesting of mousemoves
determinig if the mouse is positioned over any listbox-item which is longer
than the listbox itself.
If this happens, I'd like to show the tooltip to display the whole text.
::SendMessage(hwndTT, TTM_UPDATETIPTEXT, 0, (LPARAM)&ttInfo);
::SendMessage(hwndTT, TTM_TRACKPOSITION, 0,
(LPARAM)MAKELONG(listboxitemrect.left, listboxitemrect.top));
::SendMessage(hwndTT, TTM_TRACKACTIVATE, TRUE, (LPARAM)(LPTOOLINFO)&ttInfo);
The problem is, that the complete thing works, no errors, listbox-item-size
determined correctly, tooltip-position determined correctly, BUT no tooltip
is shown.
And now the strange thing. If I just create a manifest-file for my
application, the tooltip gets shown.
Has anyone of you an idea, whats missing, to show the tooltip without a
manifest?
Thanks in advance!
Max
Hi,

You need to use the following API and tooltip message to initialize
and activate the tooltip control:

InitCommonControlsEx()

SendMessage() TTM_ACTIVATE

http://msdn2.microsoft.com/en-us/library/ms672653.aspx

http://msdn2.microsoft.com/en-us/library/ms650484.aspx

Kellie.
unknown
2007-09-13 15:11:40 UTC
Permalink
Thanks for your answers.
But still no working tooltip! :(

I already call InitCommonControlsEx.
Adding TTM_ACTIVATE has no effect and I believe, that sending
TTM_TRACKACTIVATE should do the same when passing TRUE as wParam.

But remember, if I just add a manifest file, it works!?!?!?

Any other ideas?
Thanks!
Max
Post by unknown
Hello!
// create ToolTip-Control
hwndTT = ::CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST,
TOOLTIPS_CLASS,
NULL, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwndListBox,
NULL, NULL, NULL);
if (__information->ToolTip == NULL)
(
return FALSE;}
::SetWindowPos(__information->ToolTip, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE
| WP_NOSIZE | SWP_NOACTIVATE);
// configure ToolTip-Control
TOOLINFO ttInfo;
::ZeroMemoryttInfo, sizeof(ttInfo));
ttInfo.cbSize = sizeof(ttInfo);
ttInfo.uFlags = TTF_TRACK | TTF_TRANSPARENT | TTF_ABSOLUTE;
ttInfo.hwnd = hwndListBox;
::SendMessage(hwndTT , TTM_SETMAXTIPWIDTH, 0, SHRT_MAX);
::SendMessage(hwndTT , TTM_ADDTOOL, 0, (LPARAM)(LPTOOLINFO)&ttInfo);
::SendMessage(hwndTT , TTM_SETTIPBKCOLOR,
(WPARAM)::GetSysColor(COLOR_HIGHLIGHT), 0);
::SendMessage(hwndTT , TTM_SETTIPTEXTCOLOR,
(WPARAM)::GetSysColorCOLOR_HIGHLIGHTTEXT), 0);
RECT __tooltiprect;
__tooltiprect.left = 0;
__tooltiprect.top = -1;
__tooltiprect.right = 0;
__tooltiprect.bottom = -1;
::SendMessage(hwndTT, TTM_SETMARGIN, 0, (LPARAM)&__tooltiprect);
HFONT __tooltipfont = (HFONT)::SendMessage(hwndListBox, WM_GETFONT, 0, 0);
::SendMessage(hwndTT, WM_SETFONT, (WPARAM)__tooltipfont, FALSE);
LONG lStyle = ::GetWindowLong(hwndTT, GWL_STYLE);
lStyle &= ~WS_BORDER;
::SetWindowLong(hwndTT, GWL_STYLE, lStyle);
As you might see, the tooltip is created as child of a listbox control.
Later I subclass the listbox control performing hittesting of mousemoves
determinig if the mouse is positioned over any listbox-item which is longer
than the listbox itself.
If this happens, I'd like to show the tooltip to display the whole text.
::SendMessage(hwndTT, TTM_UPDATETIPTEXT, 0, (LPARAM)&ttInfo);
::SendMessage(hwndTT, TTM_TRACKPOSITION, 0,
(LPARAM)MAKELONG(listboxitemrect.left, listboxitemrect.top));
::SendMessage(hwndTT, TTM_TRACKACTIVATE, TRUE,
(LPARAM)(LPTOOLINFO)&ttInfo);
The problem is, that the complete thing works, no errors,
listbox-item-size
determined correctly, tooltip-position determined correctly, BUT no tooltip
is shown.
And now the strange thing. If I just create a manifest-file for my
application, the tooltip gets shown.
Has anyone of you an idea, whats missing, to show the tooltip without a
manifest?
Thanks in advance!
Max
Hi,

You need to use the following API and tooltip message to initialize
and activate the tooltip control:

InitCommonControlsEx()

SendMessage() TTM_ACTIVATE

http://msdn2.microsoft.com/en-us/library/ms672653.aspx

http://msdn2.microsoft.com/en-us/library/ms650484.aspx

Kellie.
Ivo Beltchev
2007-09-13 15:16:46 UTC
Permalink
You have to use the correct size of the TOOLINFO struct. If you are using common controls v6 you can use sizeof(TOOLINFO). If you are using v5 you can use TTTOOLINFOA_V2_SIZE.
Post by unknown
Thanks for your answers.
But still no working tooltip! :(
I already call InitCommonControlsEx.
Adding TTM_ACTIVATE has no effect and I believe, that sending
TTM_TRACKACTIVATE should do the same when passing TRUE as wParam.
But remember, if I just add a manifest file, it works!?!?!?
Any other ideas?
Thanks!
Max
Post by unknown
Hello!
// create ToolTip-Control
hwndTT = ::CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST,
TOOLTIPS_CLASS,
NULL, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwndListBox,
NULL, NULL, NULL);
if (__information->ToolTip == NULL)
(
return FALSE;}
::SetWindowPos(__information->ToolTip, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE
| WP_NOSIZE | SWP_NOACTIVATE);
// configure ToolTip-Control
TOOLINFO ttInfo;
::ZeroMemoryttInfo, sizeof(ttInfo));
ttInfo.cbSize = sizeof(ttInfo);
ttInfo.uFlags = TTF_TRACK | TTF_TRANSPARENT | TTF_ABSOLUTE;
ttInfo.hwnd = hwndListBox;
::SendMessage(hwndTT , TTM_SETMAXTIPWIDTH, 0, SHRT_MAX);
::SendMessage(hwndTT , TTM_ADDTOOL, 0, (LPARAM)(LPTOOLINFO)&ttInfo);
::SendMessage(hwndTT , TTM_SETTIPBKCOLOR,
(WPARAM)::GetSysColor(COLOR_HIGHLIGHT), 0);
::SendMessage(hwndTT , TTM_SETTIPTEXTCOLOR,
(WPARAM)::GetSysColorCOLOR_HIGHLIGHTTEXT), 0);
RECT __tooltiprect;
__tooltiprect.left = 0;
__tooltiprect.top = -1;
__tooltiprect.right = 0;
__tooltiprect.bottom = -1;
::SendMessage(hwndTT, TTM_SETMARGIN, 0, (LPARAM)&__tooltiprect);
HFONT __tooltipfont = (HFONT)::SendMessage(hwndListBox, WM_GETFONT, 0, 0);
::SendMessage(hwndTT, WM_SETFONT, (WPARAM)__tooltipfont, FALSE);
LONG lStyle = ::GetWindowLong(hwndTT, GWL_STYLE);
lStyle &= ~WS_BORDER;
::SetWindowLong(hwndTT, GWL_STYLE, lStyle);
As you might see, the tooltip is created as child of a listbox control.
Later I subclass the listbox control performing hittesting of mousemoves
determinig if the mouse is positioned over any listbox-item which is longer
than the listbox itself.
If this happens, I'd like to show the tooltip to display the whole text.
::SendMessage(hwndTT, TTM_UPDATETIPTEXT, 0, (LPARAM)&ttInfo);
::SendMessage(hwndTT, TTM_TRACKPOSITION, 0,
(LPARAM)MAKELONG(listboxitemrect.left, listboxitemrect.top));
::SendMessage(hwndTT, TTM_TRACKACTIVATE, TRUE,
(LPARAM)(LPTOOLINFO)&ttInfo);
The problem is, that the complete thing works, no errors,
listbox-item-size
determined correctly, tooltip-position determined correctly, BUT no tooltip
is shown.
And now the strange thing. If I just create a manifest-file for my
application, the tooltip gets shown.
Has anyone of you an idea, whats missing, to show the tooltip without a
manifest?
Thanks in advance!
Max
Hi,
You need to use the following API and tooltip message to initialize
InitCommonControlsEx()
SendMessage() TTM_ACTIVATE
http://msdn2.microsoft.com/en-us/library/ms672653.aspx
http://msdn2.microsoft.com/en-us/library/ms650484.aspx
Kellie.
Hofi
2007-09-21 11:40:01 UTC
Permalink
Ivo You saved my life.
I've spent days to search for the reason of the similar problem i got.
This should be mentioned highlighted in the API documentation!
Thanks!!!
Post by Ivo Beltchev
You have to use the correct size of the TOOLINFO struct. If you are using common controls v6 you can use sizeof(TOOLINFO). If you are using v5 you can use TTTOOLINFOA_V2_SIZE.
Loading...