Tooltips not working for all controls in CFormView derived class
I can't get tooltips to show up for the windows I want in my CFormView derived class. I have copied the code from the MSDN entry on EnableToolTips(). But only two windows respond with a tooltip:
CONTROL "Tree1",IDC_TESTPLANS,"SysTreeView32",TVS_HASBUTTONS | TVS_HASLINES | TVS_EDITLABELS | TVS_SHOWSELALWAYS | WS_BORDER | WS_HSCROLL | WS_TABSTOP,1,36,85,91
CONTROL "Tab1",IDC_TABCMD,"SysTabControl32",0x0,101,0,239,181
Other windows do not respond. For these windows my function designed to catch the TTN_NEEDTEXTW and TTN_NEEDTEXTA messages is not called. Windows such as
(CCntrlView is the name of my class derived from CFormView.) And as I pointed out, I'm using the code straight from the example given in MSDN for CWnd::EnableToolTips(), with the only difference being that all my controls are created in the rc file as shown above.
Re: Tooltips not working for all controls in CFormView derived class
First edit your post to add the Code tags around code snippets! Otherwise it is hard to read/understand it!
Second, if you set a breakpoint in the beginning of the function and debug the code - will you go in there and for which controls?
Re: Tooltips not working for all controls in CFormView derived class
Wow, you are fast! Sorry about the lack of tags. I should have mentioned that I already put in a breakpoint at the beginning of the method. As expected, when the cursor is overthe control windows that show tooltips (IDC_TESTPLANS and IDC_TABCMD) the breakpoint breaks and the tooltips are displayed when the program is allowed to run. For any other control, when I have the cursor over the control, the function is not called (no break), and of course no tooltip is displayed. I should mention that IDC_TABCMD is behind other windows with only the tabs showing. When the mouse goes over the tabs of IDC_TABCMD, I get the tooltip showing. IDC_TESTPLANS is on top of IDC_TABCMD. The other windows that aren't working are also on top of IDC_TABCMD or to the side. I also tried creating one of the buttons on the fly as shown in the example for EnableToolTips. That is, I took a button's definition out of the rc file and added the following before the EnableToolTips():
It made no difference, the tooltips did not appear. I also tried it without the icon code above; still didn't work. Also I should mention that all the windows are moved to get to their initial positions, and move as the program's window changes size.
Re: Tooltips not working for all controls in CFormView derived class
Actually, that's what I tried first and is why my function is called OnTtnNeedText. I copied the same code into it. Later on when I saw the more complicated method, I tried that, but got the same result: works for the two controls mentioned above, not for the others. Since you said "also", I now tried all three, so that I have:
Re: Tooltips not working for all controls in CFormView derived class
Well, I use this technique since more than a decade and it worked for me in VC++6.0 and it is still working in VC 2010.
Could you post tha small test project reproducing your problem, so we would try to investigate it?
Re: Tooltips not working for all controls in CFormView derived class
I'd be interested but I'm not familiar with the "small test project" (I searched the FAQ and other places but couldn't find it.) Does the "small" mean I reduce my enormous program down to the simplest form that has the problem and post the code somewhere?
Re: Tooltips not working for all controls in CFormView derived class
Here is a small version that doesn't work just like (I hope) the larger version of the program. There's a difference in behavior in the small version in that most of the controls don't appear until you resize the window. And my OnTtnNeedText() is never called in the small version. The buttons that I want to have tool tips are seen in the lower left corner after resizing the window. A delete (trash can), new file and copy file buttons. Thanks a lot for your help!
Re: Tooltips not working for all controls in CFormView derived class
You forgot to add the Res subfolder to the archive.
And BTW, there are no tooltips shown for your toolbar buttons either!
I'd suggest you to start testing with a very simple "classic" SDI application with one push button... Then add additional controls...
Re: Tooltips not working for all controls in CFormView derived class
Sorry about not including the res directory. I have attached a file with the directory. To create the smalltest project, I did start with a simple default SDI project. Then I added the buttons that I cannot make tool tip functionality for, and added code to create them and resize them as they are in the original project. Other items came by default, such as the toolbar, and I'm not concerned with tool tips not working there because I made no attempt to add them. As mentioned before, the buttons I'm trying to get working are the buttons that are in the lower left corner after the user resizes the window. There is tool tip code for them, but it doesn't work. You might be able to see quickly why the tool tip code doesn't work.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.