WinCreateMenu: Difference between revisions
Appearance
Created page with " This function creates a menu window from the menu template. ==Syntax== WinCreateMenu(hwndParent, lpmt) ==Parameters== ;hwndParent (HWND) - input :Owner- and parent-window ..." |
mNo edit summary |
||
Line 1: | Line 1: | ||
This function creates a menu window from the menu template. | |||
==Syntax== | ==Syntax== | ||
WinCreateMenu(hwndParent, lpmt) | WinCreateMenu(hwndParent, lpmt) | ||
==Parameters== | ==Parameters== | ||
;hwndParent (HWND) - input | ;hwndParent (HWND) - input:Owner- and parent-window handle of the created menu window. | ||
: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. | :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== | ==Returns== | ||
; hwndMenu (HWND) - returns | ;hwndMenu (HWND) - returns:Menu-window handle. | ||
:Menu-window handle. | |||
==Errors== | ==Errors== |
Revision as of 15:08, 16 May 2023
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