Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Tooltip disappears after showing once

52 views
Skip to first unread message

Frank Cheng

unread,
Jun 26, 2008, 3:01:04 PM6/26/08
to
Hi all,

I have a simple dialog with a button (the id is 1000). I am on XP and the
manifest file is included with the executable. I tried adding a tooltip to
the button using the following code. The problem I have is that

1) If the user clicks/right-clicks the button, the tooltip will not show
again.
2) If the user mouses over the button, tooltip will show. However if tooltip
timeouts, the tooltip disappears and never shows again.

If the user hovers on and off the button, the tooltip would show correctly.
If I take out the manifest file, everything works.

I used Spy to look at the messages for the tooltip control. When there is no
manifest file, the tooltip will get TTM_RELAYEVENT and fire the timer right
away if the user hovers the button. However after the user clicks on the
button, the tooltip will not fire the timer anymore.

I tried TTM_ACTIVATE and it didn't work. I did a search on google and I
found that there were quite a few posts regarding this very same issue.
However there was no resolution

http://groups.google.com/group/microsoft.public.win32.programmer.ui/browse_thread/thread/b46916de05312985/39187db839c2a196?lnk=gst&q=TTF_SUBCLASS#39187db839c2a196

Anyone has any clue what's going on?

Thanks in advance,

Frank Cheng


#include <windows.h>
#include <commctrl.h>
HWND hwndToolTips;

BOOL CALLBACK WndProc(HWND h, UINT MyMSG, WPARAM wp, LPARAM lp)
{
TOOLINFO ti;
switch (MyMSG)
{
case WM_COMMAND:
if (wp==2) EndDialog(h,0);
break;
case WM_INITDIALOG:
hwndToolTips = CreateWindow(TOOLTIPS_CLASS,
NULL,
WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP ,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
h, NULL,
GetModuleHandle(NULL),
NULL);
if (hwndToolTips)
{
ZeroMemory(&ti,sizeof(ti));
ti.cbSize = sizeof(ti);
ti.uFlags = TTF_IDISHWND |TTF_SUBCLASS;
ti.hwnd = h;
ti.uId = (UINT)GetDlgItem(h,1000);
ti.lpszText = "ASDF";
SendMessage(hwndToolTips, TTM_ADDTOOL, 0, (LPARAM) &ti );
}
break;
}
return FALSE;
}

int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE,LPSTR lpCmdLine,int
nCmdShow)
{
INITCOMMONCONTROLSEX ics;
ics.dwSize = sizeof(ics);
ics.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&ics);
DialogBoxParam(NULL,MAKEINTRESOURCE(1),NULL,WndProc,0);
ExitProcess(0);
return 0;
}


Kellie Fitton

unread,
Jun 26, 2008, 3:27:16 PM6/26/08
to
On Jun 26, 12:01 pm, "Frank Cheng" <nore...@news.com> wrote:
> Hi all,
>
> I have a simple dialog with a button (the id is 1000). I am on XP and the
> manifest file is included with the executable. I tried adding a tooltip to
> the button using the following code. The problem I have is that
>
> 1) If the user clicks/right-clicks the button, the tooltip will not show
> again.
> 2) If the user mouses over the button, tooltip will show. However if tooltip
> timeouts, the tooltip disappears and never shows again.
>
> If the user hovers on and off the button, the tooltip would show correctly.
> If I take out the manifest file, everything works.
>
> I used Spy to look at the messages for the tooltip control. When there is no
> manifest file, the tooltip will get TTM_RELAYEVENT and fire the timer right
> away if the user hovers the button. However after the user clicks on the
> button, the tooltip will not fire the timer anymore.
>
> I tried TTM_ACTIVATE and it didn't work. I did a search on google and I
> found that there were quite a few posts regarding this very same issue.
> However there was no resolution
>
> http://groups.google.com/group/microsoft.public.win32.programmer.ui/b...
> }- Hide quoted text -
>
> - Show quoted text -

Hi,

When creating the tooltip control with the API CreateWindowEx(),
use the extended window style WS_EX_TOPMOST.

Also, you need to activate the tooltip with the following message:

SendMessage() TTM_ACTIVATE

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

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

Kellie.

Frank Cheng

unread,
Jun 26, 2008, 4:46:35 PM6/26/08
to
Here is the modify version with WS_EX_TOPMOST and TTM_ACTIVATE, still
doesn't work.

#include <windows.h>
#include <commctrl.h>

HWND hwndToolTips;

BOOL CALLBACK WndProc(HWND h, UINT MyMSG, WPARAM wp, LPARAM lp)
{
TOOLINFO ti;
switch (MyMSG)
{
case WM_COMMAND:
if (wp==2) EndDialog(h,0);
break;
case WM_INITDIALOG:

hwndToolTips = CreateWindowEx(WS_EX_TOPMOST,TOOLTIPS_CLASS,


NULL,
WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP ,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
h, NULL,
GetModuleHandle(NULL),
NULL);
if (hwndToolTips)
{
ZeroMemory(&ti,sizeof(ti));
ti.cbSize = sizeof(ti);
ti.uFlags = TTF_IDISHWND |TTF_SUBCLASS ;
ti.hwnd = h;

ti.lpszText = "ASDF";
ti.uId = (UINT)GetDlgItem(h,1000);


SendMessage(hwndToolTips, TTM_ADDTOOL, 0, (LPARAM) &ti );

SendMessage(hwndToolTips, TTM_ACTIVATE, 1, 0);
}
break;
}
return FALSE;
}

int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE,LPSTR lpCmdLine,int
nCmdShow)
{
INITCOMMONCONTROLSEX ics;
ics.dwSize = sizeof(ics);
ics.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&ics);
DialogBoxParam(NULL,MAKEINTRESOURCE(1),NULL,WndProc,0);
ExitProcess(0);
return 0;
}

"Kellie Fitton" <KELLIE...@yahoo.com>
???????:eb7a6f34-9b4e-4905...@c58g2000hsc.googlegroups.com...

Kellie Fitton

unread,
Jun 26, 2008, 5:19:53 PM6/26/08
to
> "Kellie Fitton" <KELLIEFIT...@yahoo.com>
> ???????:eb7a6f34-9b4e-4905-9cb3-2cfafc74b...@c58g2000hsc.googlegroups.com...


Hi,

Try to send the following Windows message:

SendMessage() TTM_SETTOOLINFO

http://msdn.microsoft.com/en-us/library/bb760416(VS.85).aspx

Kellie.

Frank Cheng

unread,
Jun 26, 2008, 6:15:19 PM6/26/08
to
I tried it and it didn't work, and I failed to see how sending
TTM_SETTOOLINFO is relevant to the problem.

"Kellie Fitton" <KELLIE...@yahoo.com>
???????:615c5ec2-f4c2-42b4...@k37g2000hsf.googlegroups.com...

Kellie Fitton

unread,
Jun 26, 2008, 6:27:43 PM6/26/08
to
On Jun 26, 3:15 pm, "Frank Cheng" <nore...@news.com> wrote:
> I tried it and it didn't work, and I failed to see how sending
> TTM_SETTOOLINFO is relevant to the problem.
>
> "Kellie Fitton" <KELLIEFIT...@yahoo.com>
> ???????:615c5ec2-f4c2-42b4-ac1a-5d5d1a2a1...@k37g2000hsf.googlegroups.com...


Hi,

The following weblink should give you more pointers:

http://msdn.microsoft.com/en-us/library/bb760252(VS.85).aspx

Kellie.

Frank Cheng

unread,
Jun 26, 2008, 7:45:31 PM6/26/08
to
My code was copied from that article, plus that article didn't even use any
of the things that you recommended (WS_EX_TOPMOST, TTM_ACTIVATE,
TTM_SETTOOLINFO)

"Kellie Fitton" <KELLIE...@yahoo.com>
???????:8e14acbb-222a-4930...@m44g2000hsc.googlegroups.com...

Sam

unread,
Sep 12, 2008, 7:47:01 AM9/12/08
to
Hi,
I'm also having this very problem. Unfortunately, there is no solution in
here. Has anyone been able to solve this in the meantime?
Thanks
Sam

benjamin...@gmail.com

unread,
Oct 9, 2008, 12:44:09 PM10/9/08
to
Hi,

I had the same problem and finally I found the solution on this this
thread :
http://www.codeproject.com/KB/miscctrl/tooltipzen.aspx?df=100&forumid=4069&exp=0&fr=26&select=2018653#xx2018653xx

The problem is due to the TOOLINFO size which depends on the windows
version targetted. I made the modifications proposed in the thread and
it works!

Hope it helps!

Ben

On 12 sep, 07:47, Sam <S...@discussions.microsoft.com> wrote:
> Hi,
> I'm also having this very problem. Unfortunately, there is no solution in
> here. Has anyone been able to solve this in the meantime?
> Thanks
> Sam
>
> "Frank Cheng" wrote:
> > My code was copied from that article, plus that article didn't even use any
> > of the things that you recommended (WS_EX_TOPMOST, TTM_ACTIVATE,
> > TTM_SETTOOLINFO)
>

> > "Kellie Fitton" <KELLIEFIT...@yahoo.com>
> > ???????:8e14acbb-222a-4930-9d15-9d2403d85...@m44g2000hsc.googlegroups.com...

Frank Cheng

unread,
Oct 10, 2008, 12:00:23 AM10/10/08
to
Hi Ben,

Unfortunately the thread in your last post wasn't quite related to the
problem I am having. I am on XP and I have an embedded manifest file in the
program. I make sure that I am loading Comctl32.dll v6.0. I also did

#define _WIN32_IE 0x400
#define _WIN32_WINNT 0x502

At the beginning of my source code file to ensure I got the "largest"
TOOLINFO (the one with lpReserved). I tried using

TTTOOLINFOA_V1_SIZE
TTTOOLINFOW_V1_SIZE
TTTOOLINFOA_V2_SIZE
TTTOOLINFOW_V2_SIZE
TTTOOLINFOA_V3_SIZE
TTTOOLINFOW_V3_SIZE

all of the above constants for the cbSize (I also tried compiling my program
with/without UNICODE). The problem remains. The thread you mentioned was
regarding tooltip not handling some TTM messages because the structure size
might have been initialized to something that Commctrl DLL didn't expect
(either smaller or bigger). In my case the TTM_ADDTOOL is working, however
the tooltip will not show again after you click on the control that's
associated with the tooltip. However if you have two controls (let's call
them Button1 and Button2) associated with the same tooltip, clicking on
button1 will cause the tooltip not showing for button1 again UNLESS you
mouse over to Button2, which the tooltip will work for Button2. If you then
mouse over back to button1, the tooltip will be working again. Having said
that, if you click on Button1 and never mouse over to Button2, the tooltip
will not show for Button1 again.

Thanks for looking into the issue.

Frank Cheng

<benjamin...@gmail.com> wrote in message
news:b20f89bb-6a2c-4516...@q5g2000hsa.googlegroups.com...

0 new messages