source: trunk/src/user32/oslibmenu.cpp@ 2804

Last change on this file since 2804 was 2804, checked in by sandervl, 26 years ago

Added new logging feature

File size: 3.7 KB
Line 
1/* $Id: oslibmenu.cpp,v 1.11 2000-02-16 14:34:26 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#define DBG_LOCALLOG DBG_oslibmenu
26#include "dbglocal.h"
27
28//******************************************************************************
29//******************************************************************************
30HWND OSLibWinSetMenu(HWND hwndParent, HMENU hMenu)
31{
32 // Remove current menu from window
33 HWND currMenu = WinWindowFromID( (HWND)hwndParent, FID_MENU );
34 if (currMenu)
35 {
36 dprintf(("OSLibWinSetMenu: old menu %x, new menu %x", currMenu, hMenu));
37 WinSetOwner (currMenu, HWND_OBJECT);
38 WinSetParent(currMenu, HWND_OBJECT, FALSE);
39 }
40
41 if (hMenu)
42 {
43 if(WinIsWindow(GetThreadHAB(), hMenu) == TRUE)
44 {
45 WinSetOwner (hMenu, hwndParent);
46 WinSetParent(hMenu, hwndParent, FALSE );
47 WinSetWindowUShort(hMenu, QWS_ID, FID_MENU);
48 WinSendMsg(hwndParent, WM_UPDATEFRAME, (MPARAM)FCF_MENU, 0);
49 return hMenu;
50 }
51 else {
52 dprintf(("OSLibWinSetMenu: %x = invalid menu handle", hMenu));
53 }
54 }
55 return 0;
56}
57//******************************************************************************
58//******************************************************************************
59int OSLibGetMenuItemCount(HWND hMenu)
60{
61 return (int)SHORT1FROMMR(WinSendMsg(hMenu, MM_QUERYITEMCOUNT, NULL, NULL));
62}
63//******************************************************************************
64//******************************************************************************
65HMENU OSLibWinCreateMenu(PVOID menutemplate)
66{
67 return (HMENU)WinCreateMenu(HWND_OBJECT, menutemplate);
68}
69//******************************************************************************
70//******************************************************************************
71HMENU OSLibWinCreateEmptyMenu()
72{
73 return WinCreateWindow(HWND_OBJECT, WC_MENU, NULL, MS_ACTIONBAR | 0x0008 | WS_SAVEBITS,
74 0, 0, 0, 0, HWND_OBJECT, HWND_TOP, 0, NULL, NULL);
75}
76//******************************************************************************
77//******************************************************************************
78HMENU OSLibWinCreateEmptyPopupMenu()
79{
80 return WinCreateWindow(HWND_OBJECT, WC_MENU, NULL, WS_CLIPSIBLINGS | WS_SAVEBITS,
81 0, 0, 0, 0, HWND_OBJECT, HWND_TOP, 0, NULL, NULL);
82}
83//******************************************************************************
84//Returns menu item rectange in screen coordinates
85//******************************************************************************
86BOOL OSLibGetMenuItemRect(HWND hMenu, int index, LPRECT pRect)
87{
88 RECTL rectl;
89 BOOL rc;
90 ULONG id;
91
92 //First get id from menu index
93 id = (ULONG)WinSendMsg(hMenu, MM_ITEMIDFROMPOSITION, MPARAM(index), 0);
94
95 rc = (BOOL)WinSendMsg(hMenu, MM_QUERYITEMRECT, MPARAM(id), (MPARAM)&rectl);
96 if(rc == FALSE) {
97 dprintf(("OSLibGetMenuItemRect %x %d %d failed!", hMenu, index, id));
98 return FALSE;
99 }
100 WinMapWindowPoints(hMenu, HWND_DESKTOP, (PPOINTL)&rectl, 2);
101 pRect->left = rectl.xLeft;
102 pRect->right = rectl.xRight;
103 pRect->top = OSLibQueryScreenHeight() - rectl.yTop;
104 pRect->bottom= OSLibQueryScreenHeight() - rectl.yBottom;
105 return TRUE;
106}
107//******************************************************************************
108//******************************************************************************
109
Note: See TracBrowser for help on using the repository browser.