![]() |
Brad's VB-32 Programs & Samples |
|
| Posted: 06/20/97, last update: 06/20/97 | ||
| MenuHelp Revealed... What follows is an extensive elaboration of the information found in the book "Programming Windows 95" by Charles Petzold and Paul Yao, published by Microsoft Press, 1996. The information contained herein is
solely a result of this author's observations and conclusions and should by no means be
taken as fact. Every effort has been made in an attempt to provide the most clear and
accurate information possible. If for any reason this information is not found to be clear
or accurate, the author would appreciate notification via the e-mail link at the top of
this page. |
||||||||||||||||||||||||||||||||||||||||
Overview The MenuHelp function processes the WM_MENUSELECT message and displays help text for the currently selected menu in the specified status window. It's SDK documentation indicates that handling is also provided for the WM_COMMAND message, but may have never been fully implemented. The MenuHelp function is designed to be used in a message procedure. MenuHelp also automatically displays help strings for an application's system submenus and system submenu commands. Declare Sub MenuHelp Lib "comctl32" (ByVal uMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long, _
ByVal hMainMenu As Long, _
ByVal hInst As Long, _
ByVal hwndStatus As Long, _
lpwIDs As Any)
Because the MenuHelp function may have been initially designed to handle both the WM_MENUSELECT and WM_COMMAND messages, it can become terribly complicated if both messages are taken into consideration. To simplify MenuHelp as much as possible, it's functionality for the WM_COMMAND message will be ignored.
This function does not return a value. Description While receiving the initial and subsequent WM_MENUSELECT messages, MenuHelp uses the WM_MENUSELECT parameters passed to it to reference resource strings in the specified module. It displays the strings by sending SB_SETTEXT messages to the status bar, drawing the text on the simple mode's part (255), and using the SB_NOBORDERS drawing operation. When MenuHelp receives a final WM_MENUSELECT message indicating menu mode termination (the low word in WM_MENUSELECT's wParam equals 0xFFFF), MenuHelp again sends the SB_SIMPLE message (wParam = False) to the status bar, restoring it to it's non-simple state. Remarks
This does not appear to be accurate. MenuHelp uses the
value pointed to by the lpwIDs parameter to "calculate" a string ID. It does not
"search" it's data.
Implementation Type MENUHELPID
'mhid In order for this structure to be effective, it should be
placed in an array and each element contain -the first menu item of each submenu- that
contains a submenu. In order to implement this method, the application's entire
menu structure could be placed in an array of structures similar to the one used above.
Each structure could contain the same value returned by WM_MENUSELECT when the item is
selected, i.e. uItem and MF_POPUP flag from wParam's respective low and high word values,
and the submenu's parent menu handle from the lParam value. Each structure could then
occupy the position in the array which would equal it's associated menu item's string
resource ID value. A simple search routine could be employed to retrieve any selected menu
item's position in the array, and this value be could then be passed directly to either
the wParam or lpwIDs parameter. |