Jump to content

WinLoadMenu

From EDM2
Revision as of 22:01, 6 August 2023 by Martini (talk | contribs) (Created page with " This function creates a menu window from the menu template idMenu from hmod, and returns in hwndMenu the window handle for the created window. ==Syntax== ==Parameters== ;h...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This function creates a menu window from the menu template idMenu from hmod, and returns in hwndMenu the window handle for the created window.

Syntax

Parameters

hwndFrame (HWND) - input
Owner- and parent-window handle.
HWND_DESKTOP
The desktop window
HWND_OBJECT
Object window
Other
Specified window.
hmod (HMODULE) - input
Resource identifier.
NULLHANDLE
The resource is in the .EXE file of the application.
Other
The module handle returned by the DosLoadModule or DosQueryModuleHandle call.
idMenu (ULONG) - input
Menu identifier within the resource file.
It must be greater or equal to 0 and less or equal to 0xFFFF.

Returns

hwndMenu (HWND) - returns
Menu-window handle.

Remarks

The menu window is created with its parent and owner set to hwndFrame, and with identity FID_MENU. If hwndFrame is HWND_OBJECT or a window handle returned from WinQueryObjectWindow, the menu window is created as an object window.

Action bar menus are created as child windows of the frame window and are initially visible. Submenus are initially created as object windows that are owned by the window frame.

Example Code

This example creates a menu window from the menu template (idMenuId) located in "RES.DLL" and returns a menu handle which is used by WinPopupMenu.

#define INCL_WINWINDOWMGR   /* Window Manager Functions */
#define INCL_WINMENUS       /* Window Menu Functions    */
#include <os2.h>

HWND    hwndMenu;           /* Menu window              */
HWND    hwndOwner;          /* Owner window             */
HMODULE hmodDLL;            /* resource handle          */
ULONG   idMenuid;           /* Resource menu id         */
BOOL  fSuccess;             /* Success indicator        */
HWND    hwndParent;         /* Parent window            */
ULONG   flOptions;          /* Pop-up menu options      */

if (DosQueryModuleHandle("RES.DLL",&hmodDLL))
   hwndMenu = WinLoadMenu(hwndOwner, hmodDLL, idMenuid);

flOptions = PU_MOUSEBUTTON1DOWN |
            PU_KEYBOARD |
            PU_MOUSEBUTTON1;
fSuccess =  WinPopupMenu(hwndParent,
                         hwndOwner,
                         hwndMenu,
                         0, 50, 0,
                         flOptions);


Definition

#define INCL_WINMENUS /* Or use INCL_WIN, INCL_PM, */
#include <os2.h>

HWND       hwndFrame;  /*  Owner- and parent-window handle. */
HMODULE    hmod;       /*  Resource identifier. */
ULONG      idMenu;     /*  Menu identifier within the resource file. */
HWND       hwndMenu;   /*  Menu-window handle. */

hwndMenu = WinLoadMenu(hwndFrame, hmod, idMenu);

Related Functions