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

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

Implemented Set/GetWindowRgn (not activated)

File size: 16.3 KB
Line 
1/* $Id: win32wbase.h,v 1.64 2000-01-02 20:20:02 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 NROF_WIN32WNDBYTES 8
31
32#define WIN32PM_MAGIC 0x12345678
33#define CheckMagicDword(a) (a==WIN32PM_MAGIC)
34
35typedef struct {
36 USHORT cb;
37 Win32BaseWindow *win32wnd;
38 ULONG win32CreateStruct; //or dialog create dword
39} CUSTOMWNDDATA;
40
41#define WIN32APP_USERMSGBASE 0x1000
42#define WIN32APP_POSTMSG 0x1000
43#define WIN32MSG_MAGICA 0x12345678
44#define WIN32MSG_MAGICW 0x12345679
45
46typedef struct
47{
48 ULONG Msg;
49 ULONG wParam;
50 ULONG lParam;
51} POSTMSG_PACKET;
52
53#define BROADCAST_SEND 0
54#define BROADCAST_POST 1
55
56class Win32BaseWindow : public GenericObject, public ChildWindow
57{
58public:
59 DWORD magic;
60
61 Win32BaseWindow(DWORD objType);
62 Win32BaseWindow(HWND os2Handle,VOID* win32WndProc);
63 Win32BaseWindow(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode);
64virtual ~Win32BaseWindow();
65
66virtual ULONG MsgCreate(HWND hwndFrame, HWND hwndClient);
67 ULONG MsgQuit();
68 ULONG MsgClose();
69 ULONG MsgDestroy();
70virtual ULONG MsgEnable(BOOL fEnable);
71 ULONG MsgShow(BOOL fShow);
72 ULONG MsgPosChanging(LPARAM lp);
73 ULONG MsgPosChanged(LPARAM lp);
74virtual ULONG MsgActivate(BOOL fActivate, BOOL fMinimized, HWND hwnd);
75 ULONG MsgSetFocus(HWND hwnd);
76 ULONG MsgKillFocus(HWND hwnd);
77 ULONG MsgScroll(ULONG msg, ULONG scrollCode, ULONG scrollPos);
78 ULONG MsgButton(MSG *msg);
79 ULONG MsgMouseMove(MSG *msg);
80 ULONG MsgPaint(ULONG tmp1, BOOL select = TRUE);
81 ULONG MsgEraseBackGround(HDC hdc);
82 ULONG MsgInitMenu(MSG *msg);
83 ULONG MsgHitTest(MSG *msg);
84 ULONG MsgNCPaint();
85 ULONG DispatchMsgA(MSG *msg);
86 ULONG DispatchMsgW(MSG *msg);
87
88 ULONG MsgSetText(LPSTR lpsz, LONG cch);
89 ULONG MsgGetTextLength();
90 char *MsgGetText();
91 ULONG MsgContextMenu(ULONG x,ULONG y);
92 VOID updateWindowStyle(DWORD oldExStyle,DWORD oldStyle);
93
94virtual LONG SetWindowLongA(int index, ULONG value, BOOL fUnicode = FALSE);
95virtual ULONG GetWindowLongA(int index, BOOL fUnicode = FALSE);
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 ULONG getInstance() { return hInstance; };
104 void setInstance(ULONG newinstance) { hInstance = newinstance; };
105 HWND getWindowHandle() { return Win32Hwnd; };
106 HWND getOS2WindowHandle() { return OS2Hwnd; };
107 HWND getOS2FrameWindowHandle() { return OS2HwndFrame; };
108 Win32WndClass *getWindowClass() { return windowClass; };
109
110 BOOL getIgnoreHitTest() { return fIgnoreHitTest; }
111 VOID setIgnoreHitTest(BOOL ignore) { fIgnoreHitTest = ignore; }
112
113 DWORD getWindowContextHelpId() { return contextHelpId; };
114 void setWindowContextHelpId(DWORD id){ contextHelpId = id; };
115
116 BOOL isFrameWindow();
117virtual BOOL isMDIClient();
118virtual BOOL isMDIChild();
119
120 BOOL fHasParentDC() { return fParentDC; };
121
122Win32BaseWindow *getParent();
123 void setParent(Win32BaseWindow *pwindow) { ChildWindow::SetParent((ChildWindow *)pwindow); };
124 WNDPROC getWindowProc() { return win32wndproc; };
125 void setWindowProc(WNDPROC newproc) { win32wndproc = newproc; };
126 DWORD getWindowId() { return windowId; };
127 void setWindowId(DWORD id);
128 ULONG getWindowHeight() { return rectWindow.bottom - rectWindow.top; };
129 ULONG getWindowWidth() { return rectWindow.right - rectWindow.left; };
130 ULONG getClientHeight() { return rectClient.bottom - rectClient.top; };
131 ULONG getClientWidth() { return rectClient.right - rectClient.left; };
132 BOOL isChild();
133 PRECT getClientRect() { return &rectClient; };
134 void setClientRect(PRECT rect) { rectClient = *rect; };
135 PRECT getWindowRect() { return &rectWindow; };
136 void setClientRect(LONG left, LONG top, LONG right, LONG bottom)
137 {
138 rectClient.left = left; rectClient.top = top;
139 rectClient.right = right; rectClient.bottom = bottom;
140 };
141 void setWindowRect(LONG left, LONG top, LONG right, LONG bottom)
142 {
143 rectWindow.left = left; rectWindow.top = top;
144 rectWindow.right = right; rectWindow.bottom = bottom;
145 };
146 void setWindowRect(PRECT rect) { rectWindow = *rect; };
147 DWORD getFlags() { return flags; };
148 void setFlags(DWORD newflags) { flags = newflags; };
149
150 HMENU GetMenu() { return (HMENU) OS2HwndMenu; };
151 BOOL SetMenu(ULONG hMenu);
152
153 BOOL SetIcon(HICON hIcon);
154 HICON GetIcon() { return (HICON) iconResource; };
155
156 void SetWindowRegion(HRGN hRegion) { hWindowRegion = hRegion; };
157 HRGN GetWindowRegion() { return hWindowRegion; };
158
159 BOOL ShowWindow(ULONG nCmdShow);
160 BOOL SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags);
161 BOOL SetWindowPlacement(WINDOWPLACEMENT *winpos);
162 BOOL DestroyWindow();
163 HWND SetActiveWindow();
164 HWND GetParent();
165 HWND SetParent(HWND hwndNewParent);
166 BOOL IsChild(HWND hwndParent);
167 HWND GetTopWindow();
168Win32BaseWindow *GetTopParent();
169 BOOL UpdateWindow();
170 BOOL IsIconic();
171 HWND GetWindow(UINT uCmd);
172 virtual BOOL EnableWindow(BOOL fEnable);
173 BOOL CloseWindow();
174 static HWND GetActiveWindow();
175 //Window handle has already been verified, so just return true
176 BOOL IsWindow() { return TRUE; };
177 BOOL IsDialog() { return fIsDialog; };
178 BOOL IsModalDialog() { return fIsModalDialog; };
179 BOOL IsModalDialogOwner() { return fIsModalDialogOwner; };
180 VOID setModalDialogOwner(BOOL fMDO) { fIsModalDialogOwner = fMDO; };
181 VOID setOS2HwndModalDialog(HWND aHwnd) { OS2HwndModalDialog = aHwnd; };
182 HWND getOS2HwndModalDialog() { return OS2HwndModalDialog; };
183 BOOL CanReceiveSizeMsgs() { return !fNoSizeMsg; };
184 BOOL IsWindowDestroyed() { return fIsDestroyed; };
185 BOOL IsWindowEnabled();
186 BOOL IsWindowVisible();
187 //Created with CreateWindowExA or ExW
188// BOOL IsUnicode() { return isUnicode; };
189 //Window procedure type
190 BOOL IsWindowUnicode();
191
192 BOOL GetWindowRect(PRECT pRect);
193 int GetWindowTextLength();
194 int GetWindowTextA(LPSTR lpsz, int cch);
195 int GetWindowTextW(LPWSTR lpsz, int cch);
196 BOOL SetWindowTextA(LPSTR lpsz);
197 BOOL SetWindowTextW(LPWSTR lpsz);
198 BOOL hasWindowName(LPSTR wndname, BOOL fUnicode = 0);
199Win32WndClass *getClass() { return windowClass; };
200 //CB: windowNameA isn't always the window name!
201 char *getWindowNameA() { return windowNameA; };
202Win32BaseWindow *getOwner() { return owner; };
203 void setOwner(Win32BaseWindow *newOwner) { owner = newOwner; };
204
205 SCROLLBAR_INFO *getScrollInfo(int nBar);
206 HWND getVertScrollHandle() { return hwndVertScroll; };
207 VOID setVertScrollHandle(HWND newHandle) { hwndVertScroll = newHandle; }
208 HWND getHorzScrollHandle() { return hwndHorzScroll; };
209 VOID setHorzScrollHandle(HWND newHandle) { hwndHorzScroll = newHandle; }
210 VOID subclassScrollBars(BOOL subHorz,BOOL subVert);
211 BOOL showScrollBars(BOOL changeHorz,BOOL changeVert,BOOL fShow);
212
213 LRESULT SendMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
214 LRESULT SendMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
215static LRESULT BroadcastMessageA(int type, UINT msg, WPARAM wParam, LPARAM lParam);
216static LRESULT BroadcastMessageW(int type, UINT msg, WPARAM wParam, LPARAM lParam);
217 void CallWindowHookProc(ULONG hooktype, ULONG Msg, WPARAM wParam, LPARAM lParam, BOOL fUnicode = FALSE);
218
219 LRESULT DefWindowProcA(UINT Msg, WPARAM wParam, LPARAM lParam);
220 LRESULT DefWindowProcW(UINT msg, WPARAM wParam, LPARAM lParam);
221
222 LRESULT DefWndControlColor(UINT ctlType, HDC hdc);
223 LRESULT DefWndPrint(HDC hdc,ULONG uFlags);
224
225 void NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam);
226
227Win32BaseWindow *FindWindowById(int id);
228
229 static HWND FindWindowEx(HWND hwndParent, HWND hwndChildAfter, LPSTR lpszClass, LPSTR lpszWindow,
230 BOOL fUnicode = 0);
231
232 BOOL EnumChildWindows(WNDENUMPROC lpfn, LPARAM lParam);
233 BOOL EnumThreadWindows(DWORD dwThreadId, WNDENUMPROC lpfn, LPARAM lParam);
234 BOOL EnumWindows(WNDENUMPROC lpfn, LPARAM lParam);
235
236 HWND getNextDlgTabItem(HWND hwndCtrl, BOOL fPrevious);
237 HWND getNextDlgGroupItem(HWND hwndCtrl, BOOL fPrevious);
238
239 static HWND Win32ToOS2Handle(HWND hwnd);
240 static HWND Win32ToOS2FrameHandle(HWND hwnd);
241 static HWND OS2ToWin32Handle(HWND hwnd);
242
243static Win32BaseWindow *GetWindowFromHandle(HWND hwnd);
244static Win32BaseWindow *GetWindowFromOS2Handle(HWND hwnd);
245static Win32BaseWindow *GetWindowFromOS2FrameHandle(HWND hwnd);
246
247 static void DestroyAll();
248
249 PVOID getOldFrameProc() { return pOldFrameProc; };
250 VOID setOldFrameProc(PVOID aOldFrameProc) { pOldFrameProc = aOldFrameProc; };
251 ULONG getBorderWidth() { return borderWidth; };
252 ULONG getBorderHeight() { return borderHeight; };
253
254static void NC_AdjustRectInner(LPRECT rect, DWORD style, DWORD exStyle);
255static void NC_AdjustRectOuter(LPRECT rect, DWORD style, BOOL menu, DWORD exStyle);
256static BOOL WindowNeedsWMBorder( DWORD style, DWORD exStyle );
257
258 PVOID getOldWndProc() { return pOldWndProc; }
259 VOID setOldWndProc(PVOID aOldWndProc) { pOldWndProc = aOldWndProc; }
260 BOOL isSubclassedOS2Wnd() { return fIsSubclassedOS2Wnd; };
261
262protected:
263#ifndef OS2_INCLUDED
264 BOOL CreateWindowExA(CREATESTRUCTA *lpCreateStruct, ATOM classAtom);
265#endif
266 LRESULT SendInternalMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
267 LRESULT SendInternalMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
268 void Init();
269 void setExtendedKey(ULONG virtualkey, ULONG *lParam);
270
271 HWND OS2Hwnd;
272 HWND OS2HwndFrame;
273 HWND OS2HwndMenu;
274 HWND Win32Hwnd;
275 BOOL isUnicode;
276
277 int posx, posy, width, height;
278
279 // values normally contained in the standard window words
280 ULONG dwExStyle; //GWL_EXSTYLE
281 ULONG dwStyle; //GWL_STYLE
282 WNDPROC win32wndproc; //GWL_WNDPROC
283 ULONG hInstance; //GWL_HINSTANCE
284//Moved in ChildWindow class
285///// Win32BaseWindow *parent; //GWL_HWNDPARENT
286 ULONG windowId; //GWL_ID
287 ULONG userData; //GWL_USERDATA
288
289 HWND hwndLinkAfter;
290 DWORD flags;
291 DWORD contextHelpId;
292 LONG lastHitTestVal; //Last value returned by WM_NCHITTEST handler
293 BOOL fIgnoreHitTest; //Use WinWindowFromPoint during WM_HITTEST
294
295 BOOL isIcon;
296 BOOL fFirstShow;
297 BOOL fIsDialog;
298 BOOL fIsModalDialog;
299 BOOL fIsModalDialogOwner;
300 HWND OS2HwndModalDialog;
301 BOOL fInternalMsg; //Used to distinguish between messages
302 //sent by PM and those sent by apps
303 BOOL fNoSizeMsg;
304 BOOL fIsDestroyed;
305 BOOL fDestroyWindowCalled; //DestroyWindow was called for this window
306 BOOL fCreated;
307 BOOL fTaskList; //should be listed in PM tasklist or not
308 BOOL fParentDC;
309
310 HRGN hWindowRegion;
311
312 DWORD dwThreadId; //id of thread that created this window
313 DWORD dwProcessId; //id of process that created this window
314 PVOID pOldFrameProc;
315 ULONG borderWidth;
316 ULONG borderHeight;
317
318 PVOID pOldWndProc;
319 BOOL fIsSubclassedOS2Wnd; //subclassed OS/2 window: Netscape plug-in/scrollbar
320
321 Win32BaseWindow *owner;
322 Win32Resource *iconResource;
323
324 char *windowNameA;
325 WCHAR *windowNameW;
326 ULONG wndNameLength; //including 0 terminator
327
328 ULONG *userWindowLong;
329 ULONG nrUserWindowLong;
330
331 RECT rectWindow;
332 RECT rectClient;
333
334CREATESTRUCTA *tmpcs; //temporary pointer to CREATESTRUCT used in CreateWindowEx
335 ULONG sw; //set in CreateWindowExA, used in MsgCreate method
336
337SCROLLBAR_INFO *vertScrollInfo;
338SCROLLBAR_INFO *horzScrollInfo;
339 HWND hwndHorzScroll; //os/2 handle
340 HWND hwndVertScroll; //os/2 handle
341
342Win32WndClass *windowClass;
343
344static GenericObject *windows;
345
346private:
347#ifndef OS2_INCLUDED
348 void GetMinMaxInfo(POINT *maxSize, POINT *maxPos, POINT *minTrack, POINT *maxTrack );
349 LONG HandleWindowPosChanging(WINDOWPOS *winpos);
350 LONG HandleNCLButtonDown(WPARAM wParam,LPARAM lParam);
351 LONG HandleNCLButtonUp(WPARAM wParam,LPARAM lParam);
352 LONG HandleNCLButtonDblClk(WPARAM wParam,LPARAM lParam);
353 LONG HandleSysCommand(WPARAM wParam, POINT *pt32);
354
355 LONG SendNCCalcSize(BOOL calcValidRect,
356 RECT *newWindowRect, RECT *oldWindowRect,
357 RECT *oldClientRect, WINDOWPOS *winpos,
358 RECT *newClientRect );
359
360 LONG NCHandleCalcSize(WPARAM wParam, NCCALCSIZE_PARAMS *ncsize);
361
362 LRESULT SendInternalMessage(ULONG msg, WPARAM wParam, LPARAM lParam)
363 {
364 if(isUnicode)
365 return SendInternalMessageW(msg, wParam, lParam);
366 else return SendInternalMessageA(msg, wParam, lParam);
367 }
368#else
369friend BOOL OS2ToWinMsgTranslate(void *pThdb, QMSG *os2Msg, MSG *winMsg, BOOL isUnicode, BOOL fTranslateExtraMsgs);
370#endif
371
372public:
373 void SetFakeOpen32() { WinSetDAXData (OS2Hwnd, &fakeWinBase); }
374 void RemoveFakeOpen32() { WinSetDAXData (OS2Hwnd, NULL); }
375
376 fakeOpen32WinBaseClass fakeWinBase;
377
378 BOOL isOwnDC() { return (windowClass && windowClass->getStyle() & CS_OWNDC_W); }
379 HDC getOwnDC() { return ownDC; }
380 void setOwnDC(HDC hdc) { ownDC = hdc; }
381protected:
382 HDC ownDC;
383
384 ULONG EraseBkgndFlag:1,
385 PSEraseFlag:1,
386 SuppressEraseFlag:1,
387 filler:29;
388public:
389 VOID setEraseBkgnd (BOOL erase, BOOL PSErase = FALSE)
390 { EraseBkgndFlag = erase; PSEraseFlag = PSErase; }
391 VOID setSuppressErase (BOOL erase = FALSE)
392 { SuppressEraseFlag = erase; }
393 BOOL isEraseBkgnd() { return EraseBkgndFlag; }
394 BOOL isPSErase() { return EraseBkgndFlag | PSEraseFlag; }
395 BOOL isSuppressErase() { return SuppressEraseFlag; }
396};
397
398#endif //__cplusplus
399
400#endif //__WIN32WNDBASE_H__
Note: See TracBrowser for help on using the repository browser.