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

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

Use shared memory for class & window objects

File size: 10.4 KB
Line 
1/* $Id: win32wnd.h,v 1.27 1999-08-28 14:09:30 sandervl Exp $ */
2/*
3 * Win32 Window Code for OS/2
4 *
5 *
6 * Copyright 1998-1999 Sander van Leeuwen (sandervl@xs4all.nl)
7 * Copyright 1999 Daniela Engert (dani@ngrt.de)
8 *
9 *
10 * Project Odin Software License can be found in LICENSE.TXT
11 *
12 */
13#ifndef __WIN32WND_H__
14#define __WIN32WND_H__
15
16#ifdef __cplusplus
17
18#include <win32class.h>
19#include <gen_object.h>
20#include <win32wndchild.h>
21#include <winres.h>
22
23class Win32Window;
24
25#define OFFSET_WIN32WNDPTR 0
26#define OFFSET_WIN32PM_MAGIC 4
27
28#define WIN32PM_MAGIC 0x12345678
29#define CheckMagicDword(a) (a==WIN32PM_MAGIC)
30
31typedef struct {
32 USHORT cb;
33 Win32Window *win32wnd;
34 ULONG win32CreateStruct; //or dialog create dword
35} CUSTOMWNDDATA;
36
37typedef struct
38{
39 ULONG Msg;
40 ULONG wParam;
41 ULONG lParam;
42} POSTMSG_PACKET;
43
44#define WM_WIN32_POSTMESSAGEA 0x4000
45#define WM_WIN32_POSTMESSAGEW 0x4001
46
47class Win32Window : public GenericObject, private ChildWindow
48{
49public:
50 DWORD magic;
51
52 Win32Window(DWORD objType);
53 Win32Window(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode);
54virtual ~Win32Window();
55
56virtual ULONG MsgCreate(HWND hwndOS2, ULONG initParam);
57 ULONG MsgQuit();
58 ULONG MsgClose();
59 ULONG MsgDestroy();
60 ULONG MsgEnable(BOOL fEnable);
61 ULONG MsgShow(BOOL fShow);
62 ULONG MsgPosChanging(LPARAM lp);
63 ULONG MsgPosChanged(LPARAM lp);
64 ULONG MsgMove(ULONG x, ULONG y);
65 ULONG MsgHitTest(ULONG x, ULONG y);
66 ULONG MsgSize(ULONG width, ULONG height, BOOL fMinimize, BOOL fMaximize);
67 ULONG MsgActivate(BOOL fActivate, HWND hwnd);
68 ULONG MsgSetFocus(HWND hwnd);
69 ULONG MsgKillFocus(HWND hwnd);
70 ULONG MsgCommand(ULONG cmd, ULONG Id, HWND hwnd);
71 ULONG MsgSysCommand(ULONG win32sc, ULONG x, ULONG y);
72 ULONG MsgChar(ULONG cmd, ULONG repeatcnt, ULONG scancode, ULONG vkey, ULONG keyflags);
73 ULONG MsgButton(ULONG msg, ULONG ncx, ULONG ncy, ULONG clx, ULONG cly);
74 ULONG MsgMouseMove(ULONG keystate, ULONG x, ULONG y);
75 ULONG MsgPaint(ULONG tmp1, ULONG tmp2);
76 ULONG MsgEraseBackGround(HDC hdc);
77 ULONG MsgSetText(LPSTR lpsz, LONG cch);
78 ULONG MsgGetTextLength();
79 char *MsgGetText();
80
81virtual LONG SetWindowLongA(int index, ULONG value);
82virtual ULONG GetWindowLongA(int index);
83virtual WORD SetWindowWord(int index, WORD value);
84virtual WORD GetWindowWord(int index);
85
86 DWORD getStyle() { return dwStyle; };
87 DWORD getExStyle() { return dwExStyle; };
88 HWND getWindowHandle() { return Win32Hwnd; };
89 HWND getOS2WindowHandle() { return OS2Hwnd; };
90 HWND getOS2FrameWindowHandle() { return OS2HwndFrame; };
91 Win32WndClass *getWindowClass() { return windowClass; };
92
93 BOOL isFrameWindow() { return OS2Hwnd != OS2HwndFrame; };
94 Win32Window *getParent() { return (Win32Window *)ChildWindow::GetParent(); };
95 void setParent(Win32Window *pwindow) { ChildWindow::SetParent((ChildWindow *)pwindow); };
96 WNDPROC getWindowProc() { return win32wndproc; };
97 void setWindowProc(WNDPROC newproc) { win32wndproc = newproc; };
98 DWORD getWindowId() { return windowId; };
99 void setWindowId(DWORD id) { windowId = id; };
100 ULONG getWindowHeight() { return rectClient.bottom - rectClient.top; };
101 BOOL isChild();
102 PRECT getClientRect() { return &rectClient; };
103 PRECT getWindowRect() { return &rectWindow; };
104void setClientRect(LONG left, LONG top, LONG right, LONG bottom)
105{ rectClient.left = left; rectClient.top = top;
106 rectClient.right = right; rectClient.bottom = bottom;
107};
108void setWindowRect(LONG left, LONG top, LONG right, LONG bottom)
109{ rectWindow.left = left; rectWindow.top = top;
110 rectWindow.right = right; rectWindow.bottom = bottom;
111};
112 void setWindowRect(PRECT rect) { rectWindow = *rect; };
113
114 DWORD getFlags() { return flags; };
115 void setFlags(DWORD newflags) { flags = newflags; };
116
117 HACCEL GetAccelTable() { return (HACCEL) acceltableResource; };
118 BOOL SetAccelTable(ULONG hAccel);
119
120 HMENU GetMenu() { return (HMENU) menuResource; };
121 BOOL SetMenu(ULONG hMenu);
122
123 BOOL SetIcon(HICON hIcon);
124 HICON GetIcon() { return (HICON) iconResource; };
125
126 BOOL ShowWindow(ULONG nCmdShow);
127 BOOL SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags);
128 BOOL DestroyWindow();
129 HWND SetActiveWindow();
130 HWND GetParent();
131 HWND SetParent(HWND hwndNewParent);
132 BOOL IsChild(HWND hwndParent);
133 HWND GetTopWindow();
134 BOOL UpdateWindow();
135 BOOL IsIconic();
136 HWND GetWindow(UINT uCmd);
137 BOOL EnableWindow(BOOL fEnable);
138 BOOL CloseWindow();
139 static HWND GetActiveWindow();
140 BOOL IsWindow();
141 BOOL IsWindowEnabled();
142 BOOL IsWindowVisible();
143 BOOL IsUnicode() { return isUnicode; };
144
145 BOOL GetWindowRect(PRECT pRect);
146 int GetWindowTextLengthA();
147 int GetWindowTextA(LPSTR lpsz, int cch);
148 BOOL SetWindowText(LPSTR lpsz);
149 BOOL hasWindowName(LPSTR wndname, BOOL fUnicode = 0);
150
151 LRESULT SendMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
152 LRESULT SendMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
153 BOOL PostMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
154 BOOL PostMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
155 LRESULT DefWindowProcA(UINT msg, WPARAM wParam, LPARAM lParam);
156 LRESULT DefWindowProcW(UINT msg, WPARAM wParam, LPARAM lParam);
157
158 void NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam);
159
160Win32WndClass *getClass() { return windowClass; };
161
162 static HWND FindWindowEx(HWND hwndParent, HWND hwndChildAfter, LPSTR lpszClass, LPSTR lpszWindow,
163 BOOL fUnicode = 0);
164
165static HWND Win32ToOS2Handle(HWND hwnd)
166{
167 Win32Window *window = GetWindowFromHandle(hwnd);
168
169 if(window) {
170 return window->getOS2WindowHandle();
171 }
172 else return hwnd; //OS/2 window handle
173}
174
175static HWND OS2ToWin32Handle(HWND hwnd)
176{
177 Win32Window *window = GetWindowFromOS2Handle(hwnd);
178
179 if(window) {
180 return window->getWindowHandle();
181 }
182 else return hwnd; //OS/2 window handle
183}
184
185static Win32Window *GetWindowFromHandle(HWND hwnd);
186static Win32Window *GetWindowFromOS2Handle(HWND hwnd);
187
188protected:
189 LRESULT SendInternalMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
190 LRESULT SendInternalMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
191 void Init();
192
193 HWND OS2Hwnd;
194 HWND OS2HwndFrame;
195 HWND OS2HwndMenu;
196 HWND Win32Hwnd;
197 BOOL isUnicode;
198
199 int posx, posy, width, height;
200
201 // values normally contained in the standard window words
202 ULONG dwExStyle; //GWL_EXSTYLE
203 ULONG dwStyle; //GWL_STYLE
204 WNDPROC win32wndproc; //GWL_WNDPROC
205 ULONG hInstance; //GWL_HINSTANCE
206//Moved in ChildWindow class
207///// Win32Window *parent; //GWL_HWNDPARENT
208 ULONG windowId; //GWL_ID
209 ULONG userData; //GWL_USERDATA
210
211 HWND hwndLinkAfter;
212 DWORD flags;
213 DWORD lastHitTestVal; //Last value returned by WM_NCHITTEST handler
214
215 BOOL isIcon;
216 BOOL fCreated;
217 BOOL fFirstShow;
218
219 Win32Window *owner;
220
221 Win32Resource *acceltableResource;
222 Win32Resource *menuResource;
223 Win32Resource *iconResource;
224
225 char *windowNameA;
226 WCHAR *windowNameW;
227 ULONG wndNameLength; //including 0 terminator
228
229 ULONG *userWindowLong;
230 ULONG nrUserWindowLong;
231
232 RECT rectWindow;
233 RECT rectClient;
234
235Win32WndClass *windowClass;
236
237static GenericObject *windows;
238
239private:
240#ifndef OS2_INCLUDED
241 BOOL CreateWindowExA(CREATESTRUCTA *lpCreateStruct, ATOM classAtom);
242
243 void GetMinMaxInfo(POINT *maxSize, POINT *maxPos, POINT *minTrack, POINT *maxTrack );
244
245 LONG SendNCCalcSize(BOOL calcValidRect,
246 RECT *newWindowRect, RECT *oldWindowRect,
247 RECT *oldClientRect, WINDOWPOS *winpos,
248 RECT *newClientRect );
249
250 LRESULT SendInternalMessage(ULONG msg, WPARAM wParam, LPARAM lParam)
251 {
252 if(isUnicode)
253 return SendInternalMessageW(msg, wParam, lParam);
254 else return SendInternalMessageA(msg, wParam, lParam);
255 }
256#endif
257};
258
259
260#define BUTTON_LEFTDOWN 0
261#define BUTTON_LEFTUP 1
262#define BUTTON_LEFTDBLCLICK 2
263#define BUTTON_RIGHTUP 3
264#define BUTTON_RIGHTDOWN 4
265#define BUTTON_RIGHTDBLCLICK 5
266#define BUTTON_MIDDLEUP 6
267#define BUTTON_MIDDLEDOWN 7
268#define BUTTON_MIDDLEDBLCLICK 8
269
270#define WMMOVE_LBUTTON 1
271#define WMMOVE_MBUTTON 2
272#define WMMOVE_RBUTTON 4
273#define WMMOVE_CTRL 8
274#define WMMOVE_SHIFT 16
275
276
277#define CMD_MENU 1
278#define CMD_CONTROL 2
279#define CMD_ACCELERATOR 3
280
281#define WIN32SC_SIZE 0xf000
282#define WIN32SC_MOVE 0xf010
283#define WIN32SC_MINIMIZE 0xf020
284#define WIN32SC_MAXIMIZE 0xf030
285#define WIN32SC_NEXTWINDOW 0xf040
286#define WIN32SC_PREVWINDOW 0xf050
287#define WIN32SC_CLOSE 0xf060
288#define WIN32SC_VSCROLL 0xf070
289#define WIN32SC_HSCROLL 0xf080
290#define WIN32SC_MOUSEMENU 0xf090
291#define WIN32SC_KEYMENU 0xf100
292#define WIN32SC_ARRANGE 0xf110
293#define WIN32SC_RESTORE 0xf120
294#define WIN32SC_TASKLIST 0xf130
295#define WIN32SC_SCREENSAVE 0xf140
296#define WIN32SC_HOTKEY 0xf150
297
298#define KEY_ALTDOWN 1
299#define KEY_PREVDOWN 2
300#define KEY_UP 4
301#define KEY_DEADKEY 8
302
303#endif //__cplusplus
304
305#endif //__WIN32WND_H__
Note: See TracBrowser for help on using the repository browser.