source: trunk/src/user32/win32wbase.h@ 1010

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

Rene Pronk's WM_(SYS)KEYUP/DOWN changes + SvL's dialog changes

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