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

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

isFrameWindow bugfix + MDI creation & WM_NCCALCSIZE bugfix

File size: 13.7 KB
Line 
1/* $Id: win32wbase.h,v 1.25 1999-10-16 14:51:43 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#include <scroll.h>
25
26class Win32BaseWindow;
27
28#define OFFSET_WIN32WNDPTR 0
29#define OFFSET_WIN32PM_MAGIC 4
30#define OFFSET_WIN32PM_SHAREDMEM 8
31#define NROF_WIN32WNDBYTES 12
32
33#define WIN32PM_MAGIC 0x12345678
34#define CheckMagicDword(a) (a==WIN32PM_MAGIC)
35
36#define WIN32APP_USERMSGBASE 0x1000
37
38typedef struct {
39 USHORT cb;
40 Win32BaseWindow *win32wnd;
41 ULONG win32CreateStruct; //or dialog create dword
42} CUSTOMWNDDATA;
43
44typedef struct
45{
46 ULONG Msg;
47 ULONG wParam;
48 ULONG lParam;
49} POSTMSG_PACKET;
50
51#define WM_WIN32_POSTMESSAGEA 0x4000
52#define WM_WIN32_POSTMESSAGEW 0x4001
53
54class Win32BaseWindow : public GenericObject, public ChildWindow
55{
56public:
57 DWORD magic;
58
59 Win32BaseWindow(DWORD objType);
60 Win32BaseWindow(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode);
61virtual ~Win32BaseWindow();
62
63virtual ULONG MsgCreate(HWND hwndFrame, HWND hwndClient);
64 ULONG MsgQuit();
65 ULONG MsgClose();
66 ULONG MsgDestroy();
67virtual ULONG MsgEnable(BOOL fEnable);
68 ULONG MsgShow(BOOL fShow);
69 ULONG MsgPosChanging(LPARAM lp);
70 ULONG MsgPosChanged(LPARAM lp);
71 ULONG MsgMove(ULONG x, ULONG y);
72 ULONG MsgHitTest(ULONG x, ULONG y);
73 ULONG MsgSize(ULONG width, ULONG height, BOOL fMinimize, BOOL fMaximize);
74virtual ULONG MsgActivate(BOOL fActivate, BOOL fMinimized, HWND hwnd);
75 ULONG MsgSetFocus(HWND hwnd);
76 ULONG MsgKillFocus(HWND hwnd);
77 ULONG MsgTimer(ULONG TimerID);
78 ULONG MsgScroll(ULONG msg, ULONG scrollCode, ULONG scrollPos);
79 ULONG MsgCommand(ULONG cmd, ULONG Id, HWND hwnd);
80 ULONG MsgSysCommand(ULONG win32sc, ULONG x, ULONG y);
81 ULONG MsgChar(ULONG cmd, ULONG repeatcnt, ULONG scancode, ULONG vkey, ULONG keyflags);
82 ULONG MsgKeyUp (ULONG repeatCount, ULONG scancode, ULONG virtualKey);
83 ULONG MsgKeyDown (ULONG repeatCount, ULONG scancode, ULONG virtualKey, BOOL keyWasPressed);
84 ULONG MsgSysKeyUp (ULONG repeatCount, ULONG scancode, ULONG virtualKey);
85 ULONG MsgSysKeyDown (ULONG repeatCount, ULONG scancode, ULONG virtualKey, BOOL keyWasPressed);
86 ULONG MsgButton(ULONG msg, ULONG ncx, ULONG ncy, ULONG clx, ULONG cly);
87 ULONG MsgMouseMove(ULONG keystate, ULONG x, ULONG y);
88 ULONG MsgPaint(ULONG tmp1, BOOL select = TRUE);
89 ULONG MsgEraseBackGround(HDC hdc);
90 ULONG MsgSetText(LPSTR lpsz, LONG cch);
91 ULONG MsgGetTextLength();
92 char *MsgGetText();
93
94virtual LONG SetWindowLongA(int index, ULONG value);
95virtual ULONG GetWindowLongA(int index);
96virtual WORD SetWindowWord(int index, WORD value);
97virtual WORD GetWindowWord(int index);
98
99 DWORD getStyle() { return dwStyle; };
100 void setStyle(DWORD newstyle) { dwStyle = newstyle; };
101 DWORD getExStyle() { return dwExStyle; };
102 void setExStyle(DWORD newexstyle) { dwExStyle = newexstyle; };
103 HWND getWindowHandle() { return Win32Hwnd; };
104 HWND getOS2WindowHandle() { return OS2Hwnd; };
105 HWND getOS2FrameWindowHandle() { return OS2HwndFrame; };
106 Win32WndClass *getWindowClass() { return windowClass; };
107
108 BOOL isFrameWindow();
109virtual BOOL isMDIClient();
110virtual BOOL isMDIChild();
111
112Win32BaseWindow *getParent() { return (Win32BaseWindow *)ChildWindow::GetParent(); };
113 void setParent(Win32BaseWindow *pwindow) { ChildWindow::SetParent((ChildWindow *)pwindow); };
114 WNDPROC getWindowProc() { return win32wndproc; };
115 void setWindowProc(WNDPROC newproc) { win32wndproc = newproc; };
116 DWORD getWindowId() { return windowId; };
117 void setWindowId(DWORD id);
118 ULONG getWindowHeight() { return rectClient.bottom - rectClient.top; };
119 ULONG getWindowWidth() { return rectClient.right - rectClient.left; };
120 BOOL isChild();
121 PRECT getClientRect() { return &rectClient; };
122 void setClientRect(PRECT rect) { rectClient = *rect; };
123 PRECT getWindowRect() { return &rectWindow; };
124 void setClientRect(LONG left, LONG top, LONG right, LONG bottom)
125 {
126 rectClient.left = left; rectClient.top = top;
127 rectClient.right = right; rectClient.bottom = bottom;
128 };
129 void setWindowRect(LONG left, LONG top, LONG right, LONG bottom)
130 {
131 rectWindow.left = left; rectWindow.top = top;
132 rectWindow.right = right; rectWindow.bottom = bottom;
133 };
134 void setWindowRect(PRECT rect) { rectWindow = *rect; };
135 DWORD getFlags() { return flags; };
136 void setFlags(DWORD newflags) { flags = newflags; };
137
138 HACCEL GetAccelTable() { return (HACCEL) acceltableResource; };
139 BOOL SetAccelTable(ULONG hAccel);
140
141 HMENU GetMenu() { return (HMENU) OS2HwndMenu; };
142 BOOL SetMenu(ULONG hMenu);
143
144 BOOL SetIcon(HICON hIcon);
145 HICON GetIcon() { return (HICON) iconResource; };
146
147 BOOL ShowWindow(ULONG nCmdShow);
148 BOOL SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags);
149 BOOL DestroyWindow();
150 HWND SetActiveWindow();
151 HWND GetParent();
152 HWND SetParent(HWND hwndNewParent);
153 BOOL IsChild(HWND hwndParent);
154 HWND GetTopWindow();
155Win32BaseWindow *GetTopParent();
156 BOOL UpdateWindow();
157 BOOL IsIconic();
158 HWND GetWindow(UINT uCmd);
159 virtual BOOL EnableWindow(BOOL fEnable);
160 BOOL CloseWindow();
161 static HWND GetActiveWindow();
162 //Window handle has already been verified, so just return true
163 BOOL IsWindow() { return TRUE; };
164 BOOL IsDialog() { return fIsDialog; };
165
166 BOOL CanReceiveSizeMsgs() { return !fNoSizeMsg; };
167 BOOL IsWindowDestroyed() { return fIsDestroyed; };
168 BOOL IsWindowEnabled();
169 BOOL IsWindowVisible();
170 BOOL IsUnicode() { return isUnicode; };
171 BOOL GetWindowRect(PRECT pRect);
172 int GetWindowTextLength();
173 int GetWindowTextA(LPSTR lpsz, int cch);
174 int GetWindowTextW(LPWSTR lpsz, int cch);
175 BOOL SetWindowTextA(LPSTR lpsz);
176 BOOL SetWindowTextW(LPWSTR lpsz);
177 BOOL hasWindowName(LPSTR wndname, BOOL fUnicode = 0);
178Win32WndClass *getClass() { return windowClass; };
179 char *getWindowNameA() { return windowNameA; };
180Win32BaseWindow *getOwner() { return owner; };
181
182Win32BaseWindow *getTopParent();
183 SCROLLBAR_INFO *getScrollInfo(int nBar);
184 LONG setScrollInfo(int nBar, SCROLLINFO *info, int fRedraw);
185 HWND getVertScrollHandle() { return hwndVertScroll; };
186 HWND getHorzScrollHandle() { return hwndHorzScroll; };
187
188 LRESULT SendMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
189 LRESULT SendMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
190 BOOL PostMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
191 BOOL PostMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
192 LRESULT DefWindowProcA(UINT msg, WPARAM wParam, LPARAM lParam);
193 LRESULT DefWindowProcW(UINT msg, WPARAM wParam, LPARAM lParam);
194
195 LRESULT DefWndControlColor(UINT ctlType, HDC hdc);
196
197 void NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam);
198
199 static HWND FindWindowEx(HWND hwndParent, HWND hwndChildAfter, LPSTR lpszClass, LPSTR lpszWindow,
200 BOOL fUnicode = 0);
201
202 static HWND Win32ToOS2Handle(HWND hwnd);
203 static HWND Win32ToOS2FrameHandle(HWND hwnd);
204 static HWND OS2ToWin32Handle(HWND hwnd);
205
206static Win32BaseWindow *GetWindowFromHandle(HWND hwnd);
207static Win32BaseWindow *GetWindowFromOS2Handle(HWND hwnd);
208static Win32BaseWindow *GetWindowFromOS2FrameHandle(HWND hwnd);
209
210 PVOID getOldFrameProc() { return pOldFrameProc; };
211 VOID setOldFrameProc(PVOID aOldFrameProc) { pOldFrameProc = aOldFrameProc; };
212 ULONG getBorderWidth() { return borderWidth; };
213 ULONG getBorderHeight() { return borderHeight; };
214
215protected:
216#ifndef OS2_INCLUDED
217 BOOL CreateWindowExA(CREATESTRUCTA *lpCreateStruct, ATOM classAtom);
218#endif
219 LRESULT SendInternalMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
220 LRESULT SendInternalMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
221 void Init();
222 void setExtendedKey(ULONG virtualkey, ULONG *lParam);
223
224 HWND OS2Hwnd;
225 HWND OS2HwndFrame;
226 HWND OS2HwndMenu;
227 HWND Win32Hwnd;
228 BOOL isUnicode;
229
230 int posx, posy, width, height;
231
232 // values normally contained in the standard window words
233 ULONG dwExStyle; //GWL_EXSTYLE
234 ULONG dwStyle; //GWL_STYLE
235 WNDPROC win32wndproc; //GWL_WNDPROC
236 ULONG hInstance; //GWL_HINSTANCE
237//Moved in ChildWindow class
238///// Win32BaseWindow *parent; //GWL_HWNDPARENT
239 ULONG windowId; //GWL_ID
240 ULONG userData; //GWL_USERDATA
241
242 HWND hwndLinkAfter;
243 DWORD flags;
244 DWORD lastHitTestVal; //Last value returned by WM_NCHITTEST handler
245
246 BOOL isIcon;
247 BOOL fFirstShow;
248 BOOL fIsDialog;
249 BOOL fInternalMsg; //Used to distinguish between messages
250 //sent by PM and those sent by apps
251 BOOL fNoSizeMsg;
252 BOOL fIsDestroyed;
253
254 PVOID pOldFrameProc;
255 ULONG borderWidth;
256 ULONG borderHeight;
257
258 Win32BaseWindow *owner;
259
260 Win32Resource *acceltableResource;
261 Win32Resource *iconResource;
262
263 char *windowNameA;
264 WCHAR *windowNameW;
265 ULONG wndNameLength; //including 0 terminator
266
267 ULONG *userWindowLong;
268 ULONG nrUserWindowLong;
269
270 RECT rectWindow;
271 RECT rectClient;
272
273CREATESTRUCTA *tmpcs; //temporary pointer to CREATESTRUCT used in CreateWindowEx
274 ULONG sw; //set in CreateWindowExA, used in MsgCreate method
275
276SCROLLBAR_INFO *vertScrollInfo;
277SCROLLBAR_INFO *horzScrollInfo;
278 HWND hwndHorzScroll; //os/2 handle
279 HWND hwndVertScroll; //os/2 handle
280
281Win32WndClass *windowClass;
282
283static GenericObject *windows;
284
285private:
286#ifndef OS2_INCLUDED
287 void GetMinMaxInfo(POINT *maxSize, POINT *maxPos, POINT *minTrack, POINT *maxTrack );
288 LONG HandleSysCommand(WPARAM wParam, POINT *pt32);
289
290 LONG SendNCCalcSize(BOOL calcValidRect,
291 RECT *newWindowRect, RECT *oldWindowRect,
292 RECT *oldClientRect, WINDOWPOS *winpos,
293 RECT *newClientRect );
294
295 LONG NCHandleCalcSize(WPARAM wParam, NCCALCSIZE_PARAMS *ncsize);
296
297 LRESULT SendInternalMessage(ULONG msg, WPARAM wParam, LPARAM lParam)
298 {
299 if(isUnicode)
300 return SendInternalMessageW(msg, wParam, lParam);
301 else return SendInternalMessageA(msg, wParam, lParam);
302 }
303#endif
304
305public:
306 void SetFakeOpen32() { WinSetDAXData (OS2Hwnd, &fakeWinBase); }
307 void RemoveFakeOpen32() { WinSetDAXData (OS2Hwnd, NULL); }
308
309 fakeOpen32WinBaseClass fakeWinBase;
310
311 BOOL isOwnDC() { return (windowClass->getStyle() & CS_OWNDC_W); }
312 HDC getOwnDC() { return ownDC; }
313 void setOwnDC(HDC hdc) { ownDC = hdc; }
314protected:
315 HDC ownDC;
316
317 ULONG EraseBkgndFlag:1,
318 PSEraseFlag:1,
319 SupressEraseFlag:1,
320 filler:29;
321public:
322 VOID setEraseBkgnd (BOOL erase, BOOL PSErase = FALSE)
323 { EraseBkgndFlag = erase; PSEraseFlag = PSErase; }
324 VOID setSupressErase (BOOL erase = FALSE)
325 { SupressEraseFlag = erase; }
326 BOOL isEraseBkgnd() { return EraseBkgndFlag; }
327 BOOL isPSErase() { return EraseBkgndFlag | PSEraseFlag; }
328 BOOL isSupressErase() { return SupressEraseFlag; }
329};
330
331
332#define BUTTON_LEFTDOWN 0
333#define BUTTON_LEFTUP 1
334#define BUTTON_LEFTDBLCLICK 2
335#define BUTTON_RIGHTUP 3
336#define BUTTON_RIGHTDOWN 4
337#define BUTTON_RIGHTDBLCLICK 5
338#define BUTTON_MIDDLEUP 6
339#define BUTTON_MIDDLEDOWN 7
340#define BUTTON_MIDDLEDBLCLICK 8
341
342#define WMMOVE_LBUTTON 1
343#define WMMOVE_MBUTTON 2
344#define WMMOVE_RBUTTON 4
345#define WMMOVE_CTRL 8
346#define WMMOVE_SHIFT 16
347
348
349#define CMD_MENU 1
350#define CMD_CONTROL 2
351#define CMD_ACCELERATOR 3
352
353#define KEY_ALTDOWN 1
354#define KEY_PREVDOWN 2
355#define KEY_UP 4
356#define KEY_DEADKEY 8
357
358#endif //__cplusplus
359
360#endif //__WIN32WNDBASE_H__
Note: See TracBrowser for help on using the repository browser.