Tool Tip Agony: ALT Key Troubles

Dear Dr. GUI:

I have implemented tool tips in my applications by subclassing the CToolBar class in Visual C++ 1.5 and overriding the OnMouseMove function. When I determine the cursor is positioned over one of the toolbar icons, I pop up a small, topmost window with the tool tip. I then call SetCapture so I will be notified when the mouse cursor is moved off the toolbar. At that time, I remove the tool tip. This all works just fine.

My problem is that SetCapture disables the alt key. If a tool tip is displayed on the screen, the user cannot press alt+f (or any shortcut key that uses alt) to select a menu. What's even worse, Windows will pass a WM_CHAR message with the f key. This sometimes has terrible effects, such as replacing a field in an active dialog box with the letter F.

Do you have a better mouse trap? I'm sure people will beat a path to your door if you do <grin>.

Randy L. Pearson
70573,441
interlink@aol.com

Dr. GUI replies:

Do I have a better mouse trap? No, but this reminds me of a personal goal of mine. I have always wanted to invent something simple and easy to produce. Something like the bottle opener or the thumbtack. It would be so unique that it would be embraced by our culture and sell in the millions. I would retire to some remote island and provide bogus treatments for the imagined ills of the rich and famous.

As luck would have it, I stumbled upon a sample in the Development Library called TOOLTIPS that implements ToolTips for your toolbar under Microsoft Visual C++ version 1.5 and Microsoft Foundation Class Library (MFC) version 2.5. If you take a look at the source file, TOOLBARX.CPP, you will notice that this sample relies upon the use of an undocumented member function (CToolBar::HitTest) of the CToolBar class to implement ToolTips without this nasty problem with the alt key.

Of course, this problem is no problem at all under Visual C++ version 2.0 because the newest release has ToolTips built into the toolbar class. If possible, it would be a very good idea for you to use version 2.0 of Visual C++ (MFC 3.0) so that you can use this built-in feature.