unknown
2007-09-13 12:55:46 UTC
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
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