| 1 | /* $Id: oslibmenu.cpp,v 1.3 1999-10-25 20:17:18 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 | WinSetOwner (currMenu, HWND_OBJECT); | 
|---|
| 34 | WinSetParent(currMenu, HWND_OBJECT, FALSE); | 
|---|
| 35 | } | 
|---|
| 36 |  | 
|---|
| 37 | if (hMenu) | 
|---|
| 38 | { | 
|---|
| 39 | if(WinIsWindow(GetThreadHAB(), hMenu) == TRUE) { | 
|---|
| 40 | WinSetOwner (hMenu, hwndParent); | 
|---|
| 41 | WinSetParent(hMenu, hwndParent, FALSE ); | 
|---|
| 42 | WinSetWindowUShort(hMenu, QWS_ID, FID_MENU); | 
|---|
| 43 | WinSendMsg(hwndParent, WM_UPDATEFRAME, (MPARAM)FCF_MENU, 0); | 
|---|
| 44 | return hMenu; | 
|---|
| 45 | } | 
|---|
| 46 | } | 
|---|
| 47 | return 0; | 
|---|
| 48 | } | 
|---|
| 49 | //****************************************************************************** | 
|---|
| 50 | //****************************************************************************** | 
|---|
| 51 | int OSLibGetMenuItemCount(HWND hMenu) | 
|---|
| 52 | { | 
|---|
| 53 | return (int)SHORT1FROMMR(WinSendMsg(hMenu, MM_QUERYITEMCOUNT, NULL, NULL)); | 
|---|
| 54 | } | 
|---|
| 55 | //****************************************************************************** | 
|---|
| 56 | //****************************************************************************** | 
|---|
| 57 | HMENU OSLibWinCreateMenu(PVOID menutemplate) | 
|---|
| 58 | { | 
|---|
| 59 | return (HMENU)WinCreateMenu(HWND_OBJECT, menutemplate); | 
|---|
| 60 | } | 
|---|
| 61 | //****************************************************************************** | 
|---|
| 62 | //****************************************************************************** | 
|---|
| 63 | HMENU OSLibWinCreateEmptyMenu() | 
|---|
| 64 | { | 
|---|
| 65 | return WinCreateWindow(HWND_OBJECT, WC_MENU, NULL, MS_ACTIONBAR | 0x0008 | WS_SAVEBITS, | 
|---|
| 66 | 0, 0, 0, 0, HWND_OBJECT, HWND_TOP, 0, NULL, NULL); | 
|---|
| 67 | } | 
|---|
| 68 | //****************************************************************************** | 
|---|
| 69 | //****************************************************************************** | 
|---|
| 70 | HMENU OSLibWinCreateEmptyPopupMenu() | 
|---|
| 71 | { | 
|---|
| 72 | return WinCreateWindow(HWND_OBJECT, WC_MENU, NULL, WS_CLIPSIBLINGS | WS_SAVEBITS, | 
|---|
| 73 | 0, 0, 0, 0, HWND_OBJECT, HWND_TOP, 0, NULL, NULL); | 
|---|
| 74 | } | 
|---|
| 75 | //****************************************************************************** | 
|---|
| 76 | //****************************************************************************** | 
|---|
| 77 |  | 
|---|