Click to See Complete Forum and Search --> : Balloon tooltips


dit6a9
April 21st, 2005, 03:48 AM
Can anyone show me an easy example using balloon tooltips? I've checked Balloon tooltips (http://msdn.microsoft.com/library/en-us/shellcc/platform/commctls/tooltip/usingtooltips.asp?frame=true#tooltip_sample_balloon) but it is not very clear to me. For example, how can I put a message "Click here" into the balloon and how can I detect user has clicked? And how can I make the message to be underlined when user passes over it with the mouse?

RoyK
April 21st, 2005, 10:43 PM
I think it would be easier if you asked questions on what you didn't understand abou the example. You may not be able to underline it.
You set the output here:
char strTT[30] = "This is your ToolTip string.";

Though it looks like it got truncated.

you also might want to look at: http://www.codeproject.com/miscctrl/intellitip.asp

dit6a9
April 21st, 2005, 11:14 PM
Thanks for your answer.

The code from the example is more or less quite clear:

hwndToolTips = CreateWindow(TOOLTIPS_CLASS,
NULL,
WS_POPUP | TTS_NOPREFIX | TTS_BALLOON,
0, 0,
0, 0,
NULL, NULL,
g_hinst,
NULL);
if (hwndTooltip)
{
// Do the standard ToolTip coding.
TOOLINFO ti;

ti.cbSize = sizeof(ti);
ti.uFlags = TTF_TRANSPARENT | TTF_CENTERTIP;
ti.hwnd = hwnd;
ti.uId = 0;
ti.hinst = NULL;
ti.lpszText = LPSTR_TEXTCALLBACK;

GetClientRect(hwnd, &ti.rect);
SendMessage(hwndToolTips, TTM_ADDTOOL, 0, (LPARAM) &ti );
}


With this code you can create a ballooon tooltip. But, which gui element is this balloon tooltip attached to? The window referred by the hwnd variable? Suppose the hwnd variable is referring to a dialog box, when is the balloon tooltip is going to show? When the user passes over any element (button, list, etc.) contained in the dialog box?

The other thing that I can't see is how the application is notified when the user clicks on the balloon tooltip. Which message is received by the window procedure, or the dialog procedure so that I can detect the user has clicked on the balloon tooltip? I mean, when you use a button in a dialog box you can process button clicks by something like this:

BOOL CALLBACK DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg) {
case WM_COMMAND:
{
switch(LOWORD(wParam)) {
case BUTTON2_ID:
{
/* user has clicked button 2 */
...
break;
}
}
break;
}
...
default: return FALSE;
}
return TRUE;
}

Well, which is the equivalent code that detects and processes balloon tooltip clicks?

RoyK
April 22nd, 2005, 10:48 AM
Not positive, but I think it's going to attact the tip to what ever g_hinst is pointing to.