source: trunk/src/user32/new/win32wnd.h@ 338

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

Menus now work

File size: 6.8 KB
Line 
1/* $Id: win32wnd.h,v 1.14 1999-07-19 13:58:39 sandervl Exp $ */
2/*
3 * Win32 Window Code for OS/2
4 *
5 *
6 * Copyright 1998-1999 Sander van Leeuwen (sandervl@xs4all.nl)
7 *
8 *
9 * Project Odin Software License can be found in LICENSE.TXT
10 *
11 */
12#ifndef __WIN32WND_H__
13#define __WIN32WND_H__
14
15#ifdef __cplusplus
16
17#include <win32class.h>
18#include <gen_object.h>
19#include <win32wndchild.h>
20
21class Win32Window;
22
23#define OFFSET_WIN32WNDPTR 0
24#define OFFSET_WIN32PM_MAGIC 4
25
26#define WIN32PM_MAGIC 0x12345678
27#define CheckMagicDword(a) (a==WIN32PM_MAGIC)
28
29typedef struct {
30 USHORT cb;
31 Win32Window *win32wnd;
32 ULONG win32CreateStruct; //or dialog create dword
33} CUSTOMWNDDATA;
34
35typedef struct
36{
37 ULONG Msg;
38 ULONG wParam;
39 ULONG lParam;
40} POSTMSG_PACKET;
41
42#define WM_WIN32_POSTMESSAGEA 0x4000
43#define WM_WIN32_POSTMESSAGEW 0x4001
44
45class Win32Window : private GenericObject, private ChildWindow
46{
47public:
48 DWORD magic;
49
50 Win32Window(DWORD objType);
51 Win32Window(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode);
52virtual ~Win32Window();
53
54virtual ULONG MsgCreate(HWND hwndOS2, ULONG initParam);
55 ULONG MsgQuit();
56 ULONG MsgClose();
57 ULONG MsgDestroy();
58 ULONG MsgEnable(BOOL fEnable);
59 ULONG MsgShow(BOOL fShow);
60 ULONG MsgMove(ULONG x, ULONG y);
61 ULONG MsgHitTest(ULONG x, ULONG y);
62 ULONG MsgSize(ULONG width, ULONG height, BOOL fMinimize, BOOL fMaximize);
63 ULONG MsgActivate(BOOL fActivate, HWND hwnd);
64 ULONG MsgSetFocus(HWND hwnd);
65 ULONG MsgKillFocus(HWND hwnd);
66 ULONG MsgCommand(ULONG cmd, ULONG Id, HWND hwnd);
67 ULONG MsgButton(ULONG msg, ULONG x, ULONG y);
68 ULONG MsgMouseMove(ULONG keystate, ULONG x, ULONG y);
69 ULONG MsgPaint(ULONG tmp1, ULONG tmp2);
70 ULONG MsgEraseBackGround(ULONG hps);
71 ULONG MsgSetText(LPSTR lpsz, LONG cch);
72
73virtual LONG SetWindowLongA(int index, ULONG value);
74virtual ULONG GetWindowLongA(int index);
75virtual WORD SetWindowWord(int index, WORD value);
76virtual WORD GetWindowWord(int index);
77
78 DWORD getStyle() { return dwStyle; };
79 DWORD getExStyle() { return dwExStyle; };
80 HWND getWindowHandle() { return Win32Hwnd; };
81 HWND getOS2WindowHandle() { return OS2Hwnd; };
82 Win32Window *getParent() { return (Win32Window *)ChildWindow::GetParent(); };
83 void setParent(Win32Window *pwindow) { ChildWindow::SetParent((ChildWindow *)pwindow); };
84 WNDPROC getWindowProc() { return win32wndproc; };
85 void setWindowProc(WNDPROC newproc) { win32wndproc = newproc; };
86 DWORD getWindowId() { return windowId; };
87 void setWindowId(DWORD id) { windowId = id; };
88
89 DWORD getFlags() { return flags; };
90 void setFlags(DWORD newflags) { flags = newflags; };
91
92 BOOL SetMenu(ULONG hMenu);
93 BOOL ShowWindow(ULONG nCmdShow);
94 BOOL SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags);
95 BOOL DestroyWindow();
96 HWND SetActiveWindow();
97 HWND GetParent();
98 HWND SetParent(HWND hwndNewParent);
99 BOOL IsChild(HWND hwndParent);
100 HWND GetTopWindow();
101 BOOL UpdateWindow();
102 BOOL IsIconic();
103 HWND GetWindow(UINT uCmd);
104 BOOL EnableWindow(BOOL fEnable);
105 BOOL CloseWindow();
106 BOOL BringWindowToTop();
107 static HWND GetActiveWindow();
108 BOOL IsWindow();
109 BOOL IsWindowEnabled();
110 BOOL IsWindowVisible();
111 BOOL IsUnicode() { return isUnicode; };
112
113 BOOL GetWindowRect(PRECT pRect);
114 int GetWindowTextLengthA();
115 int GetWindowTextA(LPSTR lpsz, int cch);
116 BOOL SetWindowTextA(LPCSTR lpsz);
117
118 LRESULT SendMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
119 LRESULT SendMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
120 BOOL PostMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
121 BOOL PostMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
122 LRESULT DefWindowProcA(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
123 LRESULT DefWindowProcW(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
124
125 void NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam);
126
127Win32WndClass *getClass() { return windowClass; };
128
129static HWND Win32ToOS2Handle(HWND hwnd)
130{
131 Win32Window *window = GetWindowFromHandle(hwnd);
132
133 if(window) {
134 return window->getOS2WindowHandle();
135 }
136 else return hwnd; //OS/2 window handle
137}
138
139static HWND OS2ToWin32Handle(HWND hwnd)
140{
141 Win32Window *window = GetWindowFromOS2Handle(hwnd);
142
143 if(window) {
144 return window->getWindowHandle();
145 }
146 else return hwnd; //OS/2 window handle
147}
148
149static Win32Window *GetWindowFromHandle(HWND hwnd);
150static Win32Window *GetWindowFromOS2Handle(HWND hwnd);
151
152protected:
153 LRESULT SendInternalMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
154 LRESULT SendInternalMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
155 void Init();
156
157 HWND OS2Hwnd;
158 HWND OS2HwndFrame;
159 HWND OS2HwndMenu;
160 HWND Win32Hwnd;
161 BOOL isUnicode;
162
163 int posx, posy, width, height;
164
165 // values normally contained in the standard window words
166 ULONG dwExStyle; //GWL_EXSTYLE
167 ULONG dwStyle; //GWL_STYLE
168 WNDPROC win32wndproc; //GWL_WNDPROC
169 ULONG hInstance; //GWL_HINSTANCE
170//Moved in ChildWindow class
171///// Win32Window *parent; //GWL_HWNDPARENT
172 ULONG windowId; //GWL_ID
173 ULONG userData; //GWL_USERDATA
174
175 HWND hwndLinkAfter;
176 DWORD flags;
177 DWORD lastHitTestVal; //Last value returned by WM_NCHITTEST handler
178
179 BOOL isIcon;
180
181 Win32Window *owner;
182
183 char *windowName;
184 ULONG wndNameLength;
185
186 char *windowText;
187 ULONG wndTextLength;
188
189 ULONG *userWindowLong;
190 ULONG nrUserWindowLong;
191
192 RECT rectWindow;
193 RECT rectClient;
194
195Win32WndClass *windowClass;
196
197static GenericObject *windows;
198
199private:
200#ifndef OS2_INCLUDED
201 BOOL CreateWindowExA(CREATESTRUCTA *lpCreateStruct, ATOM classAtom);
202
203 void GetMinMaxInfo(POINT *maxSize, POINT *maxPos, POINT *minTrack, POINT *maxTrack );
204
205 LONG SendNCCalcSize(BOOL calcValidRect,
206 RECT *newWindowRect, RECT *oldWindowRect,
207 RECT *oldClientRect, WINDOWPOS *winpos,
208 RECT *newClientRect );
209
210 LRESULT SendInternalMessage(ULONG msg, WPARAM wParam, LPARAM lParam)
211 {
212 if(isUnicode)
213 return SendInternalMessageW(msg, wParam, lParam);
214 else return SendInternalMessageA(msg, wParam, lParam);
215 }
216#endif
217};
218
219
220#define BUTTON_LEFTDOWN 0
221#define BUTTON_LEFTUP 1
222#define BUTTON_LEFTDBLCLICK 2
223#define BUTTON_RIGHTUP 3
224#define BUTTON_RIGHTDOWN 4
225#define BUTTON_RIGHTDBLCLICK 5
226#define BUTTON_MIDDLEUP 6
227#define BUTTON_MIDDLEDOWN 7
228#define BUTTON_MIDDLEDBLCLICK 8
229
230#define WMMOVE_LBUTTON 1
231#define WMMOVE_MBUTTON 2
232#define WMMOVE_RBUTTON 4
233#define WMMOVE_CTRL 8
234#define WMMOVE_SHIFT 16
235
236
237#define CMD_MENU 1
238#define CMD_CONTROL 2
239#define CMD_ACCELERATOR 3
240
241#endif //__cplusplus
242
243#endif //__WIN32WND_H__
Note: See TracBrowser for help on using the repository browser.