Microsoft KB Archive/67688

{|
 * width="100%"|

HOWTO: Retrieve Handles to Menus and Submenus

 * }

Q67688

-

The information in this article applies to:


 * Microsoft Win32 Software Development Kit (SDK), on platform(s):
 * Microsoft Windows 95
 * the operating system: Microsoft Windows NT, versions 3.5, 3.51
 * the operating system: Microsoft Windows 2000
 * Microsoft Windows Software Development Kit (SDK) versions 3.0, 3.1

-

SUMMARY
To change the contents of a menu, you must have its handle. The handle of the menu associated with a given window is available through the GetMenu function.

To obtain a reference to a particular text item in the menu, use the GetMenuString function. The definition for this function is:

  GetMenuString(hMenu, wIDItem, lpString, nMaxCount, wFlag) Where:

  hMenu     = The menu handle wIDItem  = The ID of the item or the zero-based offset of the item within the menu lpString = The buffer that is to receive the text nMaxCount = The length of the buffer wFlag    = MF_BYCOMMAND or MF_BYPOSITION NOTE: Under Windows NT 4.0 or later, you can use the superseded function GetMenuItemInfo.

If a menu item has a mnemonic, the text will contain an ampersand (&) character preceding the mnemonic character.

To obtain the handle to a submenu of the menu bar, use the GetSubMenu function. The second parameter, nPos, is the zero-based offset from the beginning of the menu.

Additional query words:

Keywords : kbMenu kbOSWinNT kbOSWin2000 kbResource kbGrpDSUser kbOSWin

Issue type : kbhowto

Technology : kbWin32SDKSearch kbAudDeveloper kbSDKSearch kbWin32sSearch