vbpslogo2.gif (19593 bytes)
Brad's VB-32 Programs & Samples

Posted: 06/20/97, last update: 06/20/97

Home

All you ever wanted to know about the status bar's MenuHelp function (and probably more... )

If you have ever taken a look at the SDK documentation for the MenuHelp function exposed by Comctl32.dll, then surely you know that it provides very little useful information as to the use of the function. I think that one reason MS decided not to completely document the function is because of it's complexity. And once implemented, it really offers little more than one can certainly more easily code themselves. But the MenuHelp function does provide two benefits. First and most notably, is it's ability to display system defined menu strings for system menus. MenuHelp also handles the SB_SETPARTS message and text drawing for it's associated status bar.

Click here if you'd like to read more about the MenuHelp function.

Since implementation of the MenuHelp function can be inherently difficult, I decided to create four different flavors of examples that demonstrate various methods of displaying descriptions of menu items in a status bar.

Examples 1 and 2 demonstrate two fairly distinct ways to use the MenuHelp function. And to be perfectly honest, both of the examples require a bit of effort to understand. There isn't a lot of code, and what code there is, is fairly well documented. But the MenuHelp function is inherently difficult to deal with. So if you want to understand the function, the information is there.

Example 3 shows how to programmatically replace all of the functionality MenuHelp offers by sending the appropriate messages to the status bar as well as how to extract and display the system submenu help strings yourself.

Example 4 goes all out. As well as not using the MenuHelp function as shown in Example 3, it successfully eliminates any need to detect the WM_MENUSELECT window message in order to display the correct help string for selected menu items. This particular example is very much a novelty...

Most of the information about the sparsely documented MenuHelp function in this demo is an extensive elaboration of information about the MenuHelp function found in Charles Petzold's "Programming Windows 95" 1996 from Microsoft Press. This fellow *knows* what time it is...

Note: Familiarity with status bar messages is recommended. Click here to jump to the status bar demo.

This demo was created using VB4-32. Examples 1-3 employ the services of Mayby Software's MsgHook subclassing control to catch the WM_MENUSELECT message, providing assistance in displaying help strings on a status bar. The control must be properly registered on the system this demo is run on.

MsgHoo32.ocx (included in Menuhelp.zip) can be registered either by running the included file "reghook.bat" or by loading it into any VB project though VB's Tools | Custom Controls dialog.

Of course in VB5, the AddressOf operator would obviously be used in conjunction with a user-defined window procedure to replace MsgHook's subclassing procedure.

Download menuhelp.zip (47kb)