I call this function in my WM_CREATE / WM_INITDIALOG, but I never see a tooltip if
the mouse hovers the rect. I do call InitCommonControlsEx() before.
?
egawtry
November 28th, 2008, 11:44 AM
At first glance:
1. Get rid of SetWindowPos().
2. Replace the CreateWindowEx with a normal CreateWindow - no TopMost.
3. Set the ID in the TOOLINFO struct.
4. Don't forget to activate the tooltips.
SendMessage(hwndTT, TTM_ACTIVATE, TRUE, 0);
5. If you are using any sort of wrapper (MFC, .NET, ATL), don't forget to enable tooltips on the parent window.
-Erik
JohnCz
November 28th, 2008, 02:15 PM
Use CreateWindowEx. Using CreateWindow may render tooltips inoperable in older versions of windows.
You can use CreateWindow, but to be on the safe side add WS_EX_TOOLWINDOW extended style. You do not have to use WS_EX_TOPMOST but using it should not do any harm.
You can indeed get rid of SetWindowPos call but it is irrelevant.
Fill TOOLINFO properly. This is a cause of your problem. If you are adding rectangle as a tool, you cannot use TTF_IDISHWND flag. If you add more rectangles, than you would have to assign ID that is unique for each rectangle. I your case it is 0.
In conclusion, removing TTF_IDISHWND flag is a fix you need.
SendMessage(hwndTT, TTM_ADDTOOL, 0, (LPARAM)&ti);
You do not have to activate tooltips, since they are created as active. Use TTM_ACTIVATE to disable/enable tooltips if needed later in the code.
CatShoe
November 28th, 2008, 10:50 PM
Thanks for the answers, I adapted my the code but still, no tooltip is showing up.
It looks like this now:
case WM_INITDIALOG:{
...
InitCommonControls();
CreateToolTip(hWnd, rectStatus, L"Test", TT_TEST);
...
I tried InitCommonControlsEx() also, but I don't think that is the problem.
TT_TEST is defined as 20001.
rectStatus is defined global as RECT rectStatus = {70, 310, 480, 350}; which is a rectangle
within my dialog client window.
I don't get a tooltip when I hover the mouse over rectTip.
JohnCz
November 29th, 2008, 08:32 AM
Something must be wrong with your rectangle coordinates.
Just for a test initialize it to 0, 0, 200, 100. This will allow you to test left upper corner area.
If you still have problems, post your code. I always test my solution before posting and it works for me.
CatShoe
November 30th, 2008, 03:57 AM
I'm pretty much helpless on that too.
The rectangle is ok, I'm drawing it with FillRect().
I'm using exactly the code I posted, I Just changed the InitCommonControls() with InitCommonControlsEx() with almost every flag.
Well, It also does not work when I setup a tooltip for any control in my dialog. Just nothing happens. Other applications on my machine can create tooltips so it must be something on my code or environment.
I'm compiling a win32 api application, written in C. Using MSVS 2008.
Help
fred100
November 30th, 2008, 06:41 AM
It has nothing to do with Rectangle coordinates.
See Google Groups where the reason why it dosn't work has been explained hundreds of times...
CatShoe
November 30th, 2008, 06:59 AM
Great comment.
Are you kidding me? Just paste a link to whatever you mean if you know for sure what
the problem is about.
JohnCz
November 30th, 2008, 10:25 AM
If you still have problems, post your code.As I said it works for me. Tested on Vista and XP.
From the code snippet you have posted, I do not see any reason for failure. I am not able to determine what is wrong without seeing code for entire application.
Maybe something you do in a main loop prevents working?
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.