Tooltips

Hi all,
How will I give tool tips for my controls in my program dialog? I use Win SDK. I have tried CreateWindowEx(..TOOLTIPCLASS), and SendMessage(..ADD_TOOL..). But something is missing and tooltips rnt getting displayed.
TIA.
[247 byte] By [leoleo] at [2007-11-18 1:39:32]
# 1 Re: Tooltips
if you want to attach tool tips to controls [ no toolbar ]
than use this code, its kinda bad but i didn't haven't anything else here:

Creating ToolTips and assigning them to controls is a lot easier than the way you have gone about it.

First thing you need to do is activate tool tips for the Parent Window (ie: the dialog)
Here is how you do it:

// Create a tool tip class and set its parent to the Parent Window
ToolTipWnd = CreateWindow(TOOLTIPS_CLASS, NULL, WS_POPUP, 0,0,0,0, hwndParent, NULL, hInst, 0);

if ( ToolTipWnd != NULL )
SendMessage(ToolTipWnd, TTM_ACTIVATE, TRUE, 0); // Send this message to Activate ToolTips for the window
// Pass a FALSE when you wish to deactivate the tool tip.

To assign a tool tip to a control do the following:
TOOLINFO toolinfo; // Tool Tip Info structure

memset(&toolinfo, 0, sizeof(TOOLINFO));

toolinfo.cbSize = sizeof(TOOLINFO);
toolinfo.hwnd = hwndParent;
toolinfo.uFlags = TTF_SUBCLASS | TTF_IDISHWND;
toolinfo.uId = ID_OF_CONTROL;
toolinfo.hinst = NULL;
toolinfo.lpszText = TipText; // Text you wish displayed when the mouse is over the control

SendMessage ( ToolTipWnd, TTM_ADDTOOL, 0, (LPARAM)&toolinfo );

For more information, just look up in MSDN "TTM"
Also, you don't have to worry about deconstruction since Windows will handle it.
Bengi at 2007-11-9 13:02:54 >
# 2 Re: Tooltips
Thank a lot, Bengi.
Though the comment dint directly address my issue, it was a great pointer to solve it.
leoleo at 2007-11-9 13:03:56 >
# 3 Re: Tooltips
Thanks a lot, Bengi.
Though the comment dint directly address my issue, it was a great pointer to solve it.
leoleo at 2007-11-9 13:04:55 >