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