1 | /* $Id: oslibmenu.cpp,v 1.4 1999-10-30 09:19:44 sandervl Exp $ */
|
---|
2 | /*
|
---|
3 | * Window Menu wrapper functions for OS/2
|
---|
4 | *
|
---|
5 | *
|
---|
6 | * Copyright 1999 Sander van Leeuwen (sandervl@xs4all.nl)
|
---|
7 | *
|
---|
8 | *
|
---|
9 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
10 | *
|
---|
11 | */
|
---|
12 | #define INCL_WIN
|
---|
13 | #define INCL_PM
|
---|
14 | #include <os2.h>
|
---|
15 | #include <os2wrap.h>
|
---|
16 | #include <stdlib.h>
|
---|
17 | #include <string.h>
|
---|
18 |
|
---|
19 | #include <misc.h>
|
---|
20 | #include <winconst.h>
|
---|
21 | #include "oslibwin.h"
|
---|
22 | #include "oslibutil.h"
|
---|
23 | #include "oslibmenu.h"
|
---|
24 |
|
---|
25 | //******************************************************************************
|
---|
26 | //******************************************************************************
|
---|
27 | HWND OSLibWinSetMenu(HWND hwndParent, HMENU hMenu)
|
---|
28 | {
|
---|
29 | // Remove current menu from window
|
---|
30 | HWND currMenu = WinWindowFromID( (HWND)hwndParent, FID_MENU );
|
---|
31 | if (currMenu)
|
---|
32 | {
|
---|
33 | dprintf(("OSLibWinSetMenu: old menu %x, new menu %x", currMenu, hMenu));
|
---|
34 | WinSetOwner (currMenu, HWND_OBJECT);
|
---|
35 | WinSetParent(currMenu, HWND_OBJECT, FALSE);
|
---|
36 | }
|
---|
37 |
|
---|
38 | if (hMenu)
|
---|
39 | {
|
---|
40 | if(WinIsWindow(GetThreadHAB(), hMenu) == TRUE)
|
---|
41 | {
|
---|
42 | WinSetOwner (hMenu, hwndParent);
|
---|
43 | WinSetParent(hMenu, hwndParent, FALSE );
|
---|
44 | WinSetWindowUShort(hMenu, QWS_ID, FID_MENU);
|
---|
45 | WinSendMsg(hwndParent, WM_UPDATEFRAME, (MPARAM)FCF_MENU, 0);
|
---|
46 | return hMenu;
|
---|
47 | }
|
---|
48 | else {
|
---|
49 | dprintf(("OSLibWinSetMenu: %x = invalid menu handle", hMenu));
|
---|
50 | }
|
---|
51 | }
|
---|
52 | return 0;
|
---|
53 | }
|
---|
54 | //******************************************************************************
|
---|
55 | //******************************************************************************
|
---|
56 | int OSLibGetMenuItemCount(HWND hMenu)
|
---|
57 | {
|
---|
58 | return (int)SHORT1FROMMR(WinSendMsg(hMenu, MM_QUERYITEMCOUNT, NULL, NULL));
|
---|
59 | }
|
---|
60 | //******************************************************************************
|
---|
61 | //******************************************************************************
|
---|
62 | HMENU OSLibWinCreateMenu(PVOID menutemplate)
|
---|
63 | {
|
---|
64 | return (HMENU)WinCreateMenu(HWND_OBJECT, menutemplate);
|
---|
65 | }
|
---|
66 | //******************************************************************************
|
---|
67 | //******************************************************************************
|
---|
68 | HMENU OSLibWinCreateEmptyMenu()
|
---|
69 | {
|
---|
70 | return WinCreateWindow(HWND_OBJECT, WC_MENU, NULL, MS_ACTIONBAR | 0x0008 | WS_SAVEBITS,
|
---|
71 | 0, 0, 0, 0, HWND_OBJECT, HWND_TOP, 0, NULL, NULL);
|
---|
72 | }
|
---|
73 | //******************************************************************************
|
---|
74 | //******************************************************************************
|
---|
75 | HMENU OSLibWinCreateEmptyPopupMenu()
|
---|
76 | {
|
---|
77 | return WinCreateWindow(HWND_OBJECT, WC_MENU, NULL, WS_CLIPSIBLINGS | WS_SAVEBITS,
|
---|
78 | 0, 0, 0, 0, HWND_OBJECT, HWND_TOP, 0, NULL, NULL);
|
---|
79 | }
|
---|
80 | //******************************************************************************
|
---|
81 | //******************************************************************************
|
---|
82 |
|
---|