WinCreateMenu
Appearance
This function creates a menu window from the menu template.
Syntax
WinCreateMenu(hwndParent, lpmt)
Parameters
- hwndParent (HWND) - input
- Owner- and parent-window handle of the created menu window.
- If this is HWND_OBJECT or a window handle returned by the WinQueryObjectWindow call, the menu window is created as an object window.
- HWND_DESKTOP
- The desktop window
- HWND_OBJECT
- Object window
- Other
- Specified window.
- lpmt (PVOID) - input
- Menu template in binary format.
Returns
- hwndMenu (HWND) - returns
- Menu-window handle.
Errors
Possible returns from WinGetLastError
- PMERR_INVALID_HWND (0x1001)
- An invalid window handle was specified.
Remarks
The menu window is created with an identity of FID_MENU.
Example Code
This code will load a menu template from a dll and then use it to add a menu to the frame window hwndFrame which has been previously created without a menu.
HMOD hmod; HWND hwndFrame, hwndMenu; USHORT idMenu = 999; BYTE lpmt; DosLoadModule(NULL, 0, "MYDLL.DLL", &hmod); /* Load menu template */ DosGetResource2(hmod, (USHORT)RT_MENU, idMenu, &lpmt); hwndMenu = WinCreateMenu(hwndFrame, lpmt); /* Create a menu */ DosFreeResource(lpmt); /* free menu template resource */
Definition
#define INCL_WINMENUS /* Or use INCL_WIN, INCL_PM, */ #include <os2.h> HWND hwndParent; /* Owner- and parent-window handle of the created menu window. */ PVOID lpmt; /* Menu template in binary format. */ HWND hwndMenu; /* Menu-window handle. */ hwndMenu = WinCreateMenu(hwndParent, lpmt);
Related Functions
- WinLoadMenu
- WinPopupMenu