On many context menus you will see an item in boldface. For example, if you right-click a text file, you will most likely see “Open” in boldface at the top of the mean. What does the boldface mean?
The boldface menu item is the default command for that menu. It represents the action that would have occurred if you had double-clicked the item instead of viewing its context menu.
In the above example, the fact that “Open” is in boldface means that if you had double-clicked the text file instead of right-clicked it, you would have opened the document.
Programmatically, the default menu item is set via the SetMenuDefaultItem function and can be retrieved with the corresponding GetMenuDefaultItem function
If you put a default menu item in a submenu, then Windows will invoke the default item in the submenu when you double-clicking the submenu’s parent. But if you put a default menu item in a top-level menu (i.e., not on a submenu), then it is your responsibility to invoke the default menu item when the user double-clicks the object that led to the menu. (This last bit should be obvious: It is the code for the object being clicked on which decides what to do on a double-click.)
We’ll see more about default menu commands next time.
0 comments