source: trunk/src/user32/new/win32wbase.h@ 2301

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

Implemented Set/GetWindowRgn (not activated)

File size: 17.4 KB
Line 
1/* $Id: win32wbase.h,v 1.15 2000-01-02 20:20:03 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 getClientRectPtr() { return &rectClient; };
134 void getClientRect(PRECT rect)
135 {
136 *rect = rectClient;
137 rectClient.right -= rectClient.left;
138 rectClient.bottom -= rectClient.top;
139 rectClient.left = rectClient.top = 0;
140 }
141 void setClientRect(PRECT rect) { rectClient = *rect; };
142 PRECT getWindowRect() { return &rectWindow; };
143 void setClientRect(LONG left, LONG top, LONG right, LONG bottom)
144 {
145 rectClient.left = left; rectClient.top = top;
146 rectClient.right = right; rectClient.bottom = bottom;
147 };
148 void setWindowRect(LONG left, LONG top, LONG right, LONG bottom)
149 {
150 rectWindow.left = left; rectWindow.top = top;
151 rectWindow.right = right; rectWindow.bottom = bottom;
152 };
153 void setWindowRect(PRECT rect) { rectWindow = *rect; };
154 DWORD getFlags() { return flags; };
155 void setFlags(DWORD newflags) { flags = newflags; };
156
157 HMENU GetMenu() { return (HMENU) OS2HwndMenu; };
158 BOOL SetMenu(ULONG hMenu);
159
160 BOOL SetIcon(HICON hIcon);
161 HICON GetIcon() { return (HICON) iconResource; };
162
163 void SetWindowRegion(HRGN hRegion) { hWindowRegion = hRegion; };
164 HRGN GetWindowRegion() { return hWindowRegion; };
165
166 BOOL ShowWindow(ULONG nCmdShow);
167 BOOL SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags);
168 BOOL SetWindowPlacement(WINDOWPLACEMENT *winpos);
169 BOOL DestroyWindow();
170 HWND SetActiveWindow();
171 HWND GetParent();
172 HWND SetParent(HWND hwndNewParent);
173 BOOL IsChild(HWND hwndParent);
174 HWND GetTopWindow();
175Win32BaseWindow *GetTopParent();
176 BOOL UpdateWindow();
177 BOOL IsIconic();
178 HWND GetWindow(UINT uCmd);
179 virtual BOOL EnableWindow(BOOL fEnable);
180 BOOL CloseWindow();
181 static HWND GetActiveWindow();
182 //Window handle has already been verified, so just return true
183 BOOL IsWindow() { return TRUE; };
184 BOOL IsDialog() { return fIsDialog; };
185 BOOL IsModalDialog() { return fIsModalDialog; };
186 BOOL IsModalDialogOwner() { return fIsModalDialogOwner; };
187 VOID setModalDialogOwner(BOOL fMDO) { fIsModalDialogOwner = fMDO; };
188 VOID setOS2HwndModalDialog(HWND aHwnd) { OS2HwndModalDialog = aHwnd; };
189 HWND getOS2HwndModalDialog() { return OS2HwndModalDialog; };
190 BOOL CanReceiveSizeMsgs() { return !fNoSizeMsg; };
191 BOOL IsWindowCreated() { return fCreated; }
192 BOOL IsWindowDestroyed() { return fIsDestroyed; };
193 BOOL IsWindowEnabled();
194 BOOL IsWindowVisible();
195 //Created with CreateWindowExA or ExW
196// BOOL IsUnicode() { return isUnicode; };
197 //Window procedure type
198 BOOL IsWindowUnicode();
199
200 BOOL GetWindowRect(PRECT pRect);
201 int GetWindowTextLength();
202 int GetWindowTextA(LPSTR lpsz, int cch);
203 int GetWindowTextW(LPWSTR lpsz, int cch);
204 BOOL SetWindowTextA(LPSTR lpsz);
205 BOOL SetWindowTextW(LPWSTR lpsz);
206 BOOL hasWindowName(LPSTR wndname, BOOL fUnicode = 0);
207 CHAR *getWindowNamePtrA();
208 WCHAR *getWindowNamePtrW();
209 VOID freeWindowNamePtr(PVOID namePtr);
210 CHAR *getWindowNameA() { return windowNameA; }; //only for MDI windows!
211 WCHAR *getWindowNameW() { return windowNameW; }; //only for MDI windows!
212Win32WndClass *getClass() { return windowClass; };
213Win32BaseWindow *getOwner() { return owner; };
214 void setOwner(Win32BaseWindow *newOwner) { owner = newOwner; };
215
216 SCROLLBAR_INFO *getScrollInfo(int nBar);
217 HWND getVertScrollHandle() { return hwndVertScroll; };
218 VOID setVertScrollHandle(HWND newHandle) { hwndVertScroll = newHandle; }
219 HWND getHorzScrollHandle() { return hwndHorzScroll; };
220 VOID setHorzScrollHandle(HWND newHandle) { hwndHorzScroll = newHandle; }
221 VOID subclassScrollBars(BOOL subHorz,BOOL subVert);
222 BOOL showScrollBars(BOOL changeHorz,BOOL changeVert,BOOL fShow);
223
224 LRESULT SendMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
225 LRESULT SendMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
226static LRESULT BroadcastMessageA(int type, UINT msg, WPARAM wParam, LPARAM lParam);
227static LRESULT BroadcastMessageW(int type, UINT msg, WPARAM wParam, LPARAM lParam);
228 void CallWindowHookProc(ULONG hooktype, ULONG Msg, WPARAM wParam, LPARAM lParam, BOOL fUnicode = FALSE);
229
230 LRESULT DefWindowProcA(UINT Msg, WPARAM wParam, LPARAM lParam);
231 LRESULT DefWindowProcW(UINT msg, WPARAM wParam, LPARAM lParam);
232
233 LRESULT DefWndControlColor(UINT ctlType, HDC hdc);
234 LRESULT DefWndPrint(HDC hdc,ULONG uFlags);
235
236 void NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam);
237
238Win32BaseWindow *FindWindowById(int id);
239
240 static HWND FindWindowEx(HWND hwndParent, HWND hwndChildAfter, LPSTR lpszClass, LPSTR lpszWindow,
241 BOOL fUnicode = 0);
242
243 BOOL EnumChildWindows(WNDENUMPROC lpfn, LPARAM lParam);
244 BOOL EnumThreadWindows(DWORD dwThreadId, WNDENUMPROC lpfn, LPARAM lParam);
245 BOOL EnumWindows(WNDENUMPROC lpfn, LPARAM lParam);
246
247 HWND getNextDlgTabItem(HWND hwndCtrl, BOOL fPrevious);
248 HWND getNextDlgGroupItem(HWND hwndCtrl, BOOL fPrevious);
249
250 static HWND Win32ToOS2Handle(HWND hwnd);
251 static HWND Win32ToOS2FrameHandle(HWND hwnd);
252 static HWND OS2ToWin32Handle(HWND hwnd);
253
254static Win32BaseWindow *GetWindowFromHandle(HWND hwnd);
255static Win32BaseWindow *GetWindowFromOS2Handle(HWND hwnd);
256static Win32BaseWindow *GetWindowFromOS2FrameHandle(HWND hwnd);
257
258 static void DestroyAll();
259
260 PVOID getOldFrameProc() { return pOldFrameProc; };
261 VOID setOldFrameProc(PVOID aOldFrameProc) { pOldFrameProc = aOldFrameProc; };
262 ULONG getBorderWidth() { return borderWidth; };
263 ULONG getBorderHeight() { return borderHeight; };
264
265 PVOID getOldWndProc() { return pOldWndProc; }
266 VOID setOldWndProc(PVOID aOldWndProc) { pOldWndProc = aOldWndProc; }
267 BOOL isSubclassedOS2Wnd() { return fIsSubclassedOS2Wnd; };
268
269protected:
270#ifndef OS2_INCLUDED
271 BOOL CreateWindowExA(CREATESTRUCTA *lpCreateStruct, ATOM classAtom);
272#endif
273 LRESULT SendInternalMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
274 LRESULT SendInternalMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
275 void Init();
276 void setExtendedKey(ULONG virtualkey, ULONG *lParam);
277
278 HWND OS2Hwnd;
279 HWND OS2HwndFrame;
280 HWND OS2HwndMenu;
281 HWND Win32Hwnd;
282 BOOL isUnicode;
283
284 int posx, posy, width, height;
285
286 // values normally contained in the standard window words
287 ULONG dwExStyle; //GWL_EXSTYLE
288 ULONG dwStyle; //GWL_STYLE
289 WNDPROC win32wndproc; //GWL_WNDPROC
290 ULONG hInstance; //GWL_HINSTANCE
291//Moved in ChildWindow class
292///// Win32BaseWindow *parent; //GWL_HWNDPARENT
293 ULONG windowId; //GWL_ID
294 ULONG userData; //GWL_USERDATA
295
296 HWND hwndLinkAfter;
297 DWORD flags;
298 DWORD contextHelpId;
299 LONG lastHitTestVal; //Last value returned by WM_NCHITTEST handler
300 BOOL fIgnoreHitTest; //Use WinWindowFromPoint during WM_HITTEST
301
302 BOOL isIcon;
303 BOOL fFirstShow;
304 BOOL fIsDialog;
305 BOOL fIsModalDialog;
306 BOOL fIsModalDialogOwner;
307 HWND OS2HwndModalDialog;
308 BOOL fInternalMsg; //Used to distinguish between messages
309 //sent by PM and those sent by apps
310 BOOL fNoSizeMsg;
311 BOOL fIsDestroyed;
312 BOOL fDestroyWindowCalled; //DestroyWindow was called for this window
313 BOOL fCreated;
314 BOOL fTaskList; //should be listed in PM tasklist or not
315 BOOL fParentDC;
316
317 HRGN hWindowRegion;
318
319 DWORD dwThreadId; //id of thread that created this window
320 DWORD dwProcessId; //id of process that created this window
321 PVOID pOldFrameProc;
322 ULONG borderWidth;
323 ULONG borderHeight;
324
325 PVOID pOldWndProc;
326 BOOL fIsSubclassedOS2Wnd; //subclassed OS/2 window: Netscape plug-in/scrollbar
327
328 Win32BaseWindow *owner;
329 Win32Resource *iconResource;
330
331 char *windowNameA;
332 WCHAR *windowNameW;
333 ULONG wndNameLength; //including 0 terminator
334
335 ULONG *userWindowLong;
336 ULONG nrUserWindowLong;
337
338 RECT rectWindow; //relative to screen
339 RECT rectClient; //relative to parent
340
341CREATESTRUCTA *tmpcs; //temporary pointer to CREATESTRUCT used in CreateWindowEx
342 ULONG sw; //set in CreateWindowExA, used in MsgCreate method
343
344SCROLLBAR_INFO *vertScrollInfo;
345SCROLLBAR_INFO *horzScrollInfo;
346 HWND hwndHorzScroll; //os/2 handle
347 HWND hwndVertScroll; //os/2 handle
348
349Win32WndClass *windowClass;
350
351static GenericObject *windows;
352
353private:
354#ifndef OS2_INCLUDED
355 void GetMinMaxInfo(POINT *maxSize, POINT *maxPos, POINT *minTrack, POINT *maxTrack );
356 LONG HandleWindowPosChanging(WINDOWPOS *winpos);
357 LONG HandleNCActivate(WPARAM wParam);
358 VOID TrackMinMaxBox(WORD wParam);
359 VOID TrackCloseButton(WORD wParam);
360 LONG HandleNCLButtonDown(WPARAM wParam,LPARAM lParam);
361 LONG HandleNCLButtonUp(WPARAM wParam,LPARAM lParam);
362 LONG HandleNCLButtonDblClk(WPARAM wParam,LPARAM lParam);
363 BOOL WindowNeedsWMBorder();
364 VOID AdjustRectOuter(LPRECT rect,BOOL menu);
365 VOID AdjustRectInner(LPRECT rect);
366 LONG HandleNCCalcSize(RECT *winRect);
367 LONG HandleNCHitTest(POINT pt);
368 VOID GetInsideRect(RECT *rect);
369 VOID DrawFrame(HDC hdc,RECT *rect,BOOL dlgFrame,BOOL active);
370 BOOL DrawSysButton(HDC hdc,BOOL down);
371 BOOL DrawGrayButton(HDC hdc,int x,int y);
372 VOID DrawCloseButton(HDC hdc,BOOL down,BOOL bGrayed);
373 VOID DrawMaxButton(HDC hdc,BOOL down,BOOL bGrayed);
374 VOID DrawMinButton(HDC hdc,BOOL down,BOOL bGrayed);
375 VOID DrawCaption(HDC hdc,RECT *rect,BOOL active);
376 VOID DoNCPaint(HRGN clip,BOOL suppress_menupaint);
377 LONG HandleNCPaint(HRGN clip);
378 LONG HandleSysCommand(WPARAM wParam, POINT *pt32);
379
380 LONG SendNCCalcSize(BOOL calcValidRect,
381 RECT *newWindowRect, RECT *oldWindowRect,
382 RECT *oldClientRect, WINDOWPOS *winpos,
383 RECT *newClientRect );
384
385 LRESULT SendInternalMessage(ULONG msg, WPARAM wParam, LPARAM lParam)
386 {
387 if(isUnicode)
388 return SendInternalMessageW(msg, wParam, lParam);
389 else return SendInternalMessageA(msg, wParam, lParam);
390 }
391#else
392friend BOOL OS2ToWinMsgTranslate(void *pThdb, QMSG *os2Msg, MSG *winMsg, BOOL isUnicode, BOOL fTranslateExtraMsgs);
393#endif
394
395public:
396 void SetFakeOpen32() { WinSetDAXData (OS2Hwnd, &fakeWinBase); }
397 void RemoveFakeOpen32() { WinSetDAXData (OS2Hwnd, NULL); }
398
399 fakeOpen32WinBaseClass fakeWinBase;
400
401 BOOL isOwnDC() { return (windowClass && windowClass->getStyle() & CS_OWNDC_W); }
402 HDC getOwnDC() { return ownDC; }
403 void setOwnDC(HDC hdc) { ownDC = hdc; }
404protected:
405 HDC ownDC;
406
407 ULONG EraseBkgndFlag:1,
408 PSEraseFlag:1,
409 SuppressEraseFlag:1,
410 filler:29;
411public:
412 VOID setEraseBkgnd (BOOL erase, BOOL PSErase = FALSE)
413 { EraseBkgndFlag = erase; PSEraseFlag = PSErase; }
414 VOID setSuppressErase (BOOL erase = FALSE)
415 { SuppressEraseFlag = erase; }
416 BOOL isEraseBkgnd() { return EraseBkgndFlag; }
417 BOOL isPSErase() { return EraseBkgndFlag | PSEraseFlag; }
418 BOOL isSuppressErase() { return SuppressEraseFlag; }
419};
420
421#endif //__cplusplus
422
423#endif //__WIN32WNDBASE_H__
Note: See TracBrowser for help on using the repository browser.