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

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

Keyboard msg fixes

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