Many programs have menus and status bars. When you move a menu by clicking the mouse and select a menu item, the description of this menu item is displayed in the status bar. This function is encapsulated by MFC and can be generated using the wizard, but you have to write your own code by using API programming. After checking msdn, A menuhelp function can be used. The function prototype is as follows:
Void menuhelp (
Uint umsg,
Wparam,
Lparam,
Hmenu hmainmenu,
Hinstance hinst,
Hwnd hwndstatus,
Lpuint lpwids
);
The preceding parameter is easy to understand. The key is the last parameter lpwids. The msdn description is a uint array pointer. The array elements must be paired. The first parameter is the string resource ID, the second is the menu handle. It seems troublesome to think about it. You have to get the handle for each menu item after the program loads the menu and then fill in this array? I did not bother writing the code for a try, but it didn't work at all. So I looked at the source code of MFC and dizzy. I did not use this function and handled it myself. Find another SDK-written routine and find that this array has only four elements, two pairs, and the second pair is 0, 0, marking the end of the array. The string resource ID in the first pair does not exist in the resource at all, the second menu handle value is 0x1100, and no operation is performed on this array in the code, but it works properly, which makes it even more dizzy. I carefully studied this "magic" program and finally learned how to use menuhelp:
Uint WIDS [] = {mh_base, 0x1100,0, 0}
This mh_base can define a value at will, but it must be ensured that the value with the menu command ID cannot exceed 0 xFFFF.
Then add a help string to the resource. The resource ID of the string must be mh_base with the corresponding menu command ID. The resource ID of the sub-menu string must be 0x1100 plus the corresponding serial number. The help string of this Sub-menu is: for example, the menu usually contains the "file" menu item, click "file" and a drop-down menu will pop up, showing "open", "close", etc. Move the mouse over these two options and display "Open File" and "close" in the status bar respectively ", if you remove these two options and the drop-down menu is not closed, the help string "File Operation" of this Sub-menu is displayed ". The second sub-menu, such as the "edit" help string resource ID, is 0x1100 + 1.
For example, if the command IDs of "open" and "close" in the menu are cm_open and cm_close, You need to define a string in the resource:
Stringtable discardable
Begin
Mh_base + cm_open "Open File"
Mh_base + cm_close "close"
0x1100 + 0 "File Operations"
End
The program responds to the wm_menuselect message and calls menuhelp (wm_menuselect, wparam, lparam, getmenu (hwnd), hinstance, hstatuswnd, WIDS.