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

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

WM_ERASEBKGND changes

File size: 18.1 KB
Line 
1/* $Id: win32wbase.h,v 1.80 2000-02-05 16:25:00 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//PostThreadMessage is done through Open32; which means the message id will be translated
42//(0xc00 added)
43#define OPEN32_MSGDIFF 0xC00
44#define WIN32APP_POSTMSG (0x1000+OPEN32_MSGDIFF)
45
46#define WIN32MSG_MAGICA 0x12345678
47#define WIN32MSG_MAGICW 0x12345679
48
49typedef struct
50{
51 ULONG Msg;
52 ULONG wParam;
53 ULONG lParam;
54} POSTMSG_PACKET;
55
56#define BROADCAST_SEND 0
57#define BROADCAST_POST 1
58
59#define HAS_DLGFRAME(style,exStyle) \
60 (((exStyle) & WS_EX_DLGMODALFRAME) || \
61 (((style) & WS_DLGFRAME) && !((style) & WS_THICKFRAME)))
62
63#define HAS_THICKFRAME(style,exStyle) \
64 (((style) & WS_THICKFRAME) && \
65 !((exStyle) & WS_EX_DLGMODALFRAME) && \
66 !((style) & WS_CHILD))
67
68#define HAS_THINFRAME(style) \
69 (((style) & WS_BORDER) || !((style) & (WS_CHILD | WS_POPUP)))
70
71#define HAS_BIGFRAME(style,exStyle) \
72 (((style) & (WS_THICKFRAME | WS_DLGFRAME)) || \
73 ((exStyle) & WS_EX_DLGMODALFRAME))
74
75#define HAS_ANYFRAME(style,exStyle) \
76 (((style) & (WS_THICKFRAME | WS_DLGFRAME | WS_BORDER)) || \
77 ((exStyle) & WS_EX_DLGMODALFRAME) || \
78 !((style) & (WS_CHILD | WS_POPUP)))
79
80#define HAS_3DFRAME(exStyle) \
81 ((exStyle & WS_EX_CLIENTEDGE) || (exStyle & WS_EX_STATICEDGE) || (exStyle & WS_EX_WINDOWEDGE))
82
83#define HAS_BORDER(style, exStyle) \
84 ((style & WS_BORDER) || HAS_THICKFRAME(style) || HAS_DLGFRAME(style,exStyle))
85
86#define IS_OVERLAPPED(style) \
87 !(style & (WS_CHILD | WS_POPUP))
88
89#define HAS_MENU() (!(getStyle() & WS_CHILD) && (GetMenu() != 0))
90
91class Win32BaseWindow : public GenericObject, public ChildWindow
92{
93public:
94 DWORD magic;
95
96 Win32BaseWindow(DWORD objType);
97 Win32BaseWindow(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode);
98virtual ~Win32BaseWindow();
99
100virtual ULONG MsgCreate(HWND hwndFrame, HWND hwndClient);
101 ULONG MsgQuit();
102 ULONG MsgClose();
103 ULONG MsgDestroy();
104virtual ULONG MsgEnable(BOOL fEnable);
105 ULONG MsgShow(BOOL fShow);
106 ULONG MsgPosChanging(LPARAM lp);
107 ULONG MsgPosChanged(LPARAM lp);
108 ULONG MsgActivate(BOOL fActivate, BOOL fMinimized, HWND hwnd, HWND hwndOS2Win);
109 ULONG MsgSetFocus(HWND hwnd);
110 ULONG MsgKillFocus(HWND hwnd);
111 ULONG MsgScroll(ULONG msg, ULONG scrollCode, ULONG scrollPos);
112 ULONG MsgButton(MSG *msg);
113 ULONG MsgMouseMove(MSG *msg);
114 ULONG MsgChar(MSG *msg);
115 ULONG MsgPaint(ULONG tmp1, BOOL select = TRUE);
116 ULONG MsgEraseBackGround(HDC hdc);
117 ULONG MsgHitTest(ULONG x, ULONG y);
118 ULONG MsgNCPaint();
119 ULONG MsgFormatFrame(WINDOWPOS *lpWndPos);
120 ULONG DispatchMsgA(MSG *msg);
121 ULONG DispatchMsgW(MSG *msg);
122
123 ULONG MsgSetText(LPSTR lpsz, LONG cch);
124 ULONG MsgGetTextLength();
125 void MsgGetText(char *wndtext, ULONG textlength);
126 VOID updateWindowStyle(DWORD oldExStyle,DWORD oldStyle);
127
128virtual LONG SetWindowLongA(int index, ULONG value, BOOL fUnicode = FALSE);
129virtual ULONG GetWindowLongA(int index, BOOL fUnicode = FALSE);
130virtual WORD SetWindowWord(int index, WORD value);
131virtual WORD GetWindowWord(int index);
132
133 DWORD getStyle() { return dwStyle; };
134 void setStyle(DWORD newstyle) { dwStyle = newstyle; };
135 DWORD getExStyle() { return dwExStyle; };
136 void setExStyle(DWORD newexstyle) { dwExStyle = newexstyle; };
137 ULONG getInstance() { return hInstance; };
138 void setInstance(ULONG newinstance) { hInstance = newinstance; };
139 HWND getWindowHandle() { return Win32Hwnd; };
140 HWND getOS2WindowHandle() { return OS2Hwnd; };
141 HWND getOS2FrameWindowHandle() { return OS2HwndFrame; };
142 Win32WndClass *getWindowClass() { return windowClass; };
143
144 LONG getLastHitTestVal() { return lastHitTestVal; }
145
146 DWORD getWindowContextHelpId() { return contextHelpId; };
147 void setWindowContextHelpId(DWORD id){ contextHelpId = id; };
148
149 BOOL isFrameWindow();
150virtual BOOL isMDIClient();
151virtual BOOL isMDIChild();
152
153 BOOL fHasParentDC() { return fParentDC; };
154
155Win32BaseWindow *getParent();
156 void setParent(Win32BaseWindow *pwindow) { ChildWindow::SetParent((ChildWindow *)pwindow); };
157 WNDPROC getWindowProc() { return win32wndproc; };
158 void setWindowProc(WNDPROC newproc) { win32wndproc = newproc; };
159 DWORD getWindowId() { return dwIDMenu; };
160 void setWindowId(DWORD id);
161 ULONG getWindowHeight() { return rectWindow.bottom - rectWindow.top; };
162 ULONG getWindowWidth() { return rectWindow.right - rectWindow.left; };
163 ULONG getClientHeight() { return rectClient.bottom - rectClient.top; };
164 ULONG getClientWidth() { return rectClient.right - rectClient.left; };
165 BOOL isChild();
166 PRECT getClientRectPtr() { return &rectClient; };
167 void getClientRect(PRECT rect)
168 {
169 *rect = rectClient;
170 rect->right -= rect->left;
171 rect->bottom -= rect->top;
172 rect->left = rect->top = 0;
173 }
174 void setClientRect(PRECT rect) { rectClient = *rect; };
175 PRECT getWindowRect() { return &rectWindow; };
176 void setClientRect(LONG left, LONG top, LONG right, LONG bottom)
177 {
178 rectClient.left = left; rectClient.top = top;
179 rectClient.right = right; rectClient.bottom = bottom;
180 };
181 void setWindowRect(LONG left, LONG top, LONG right, LONG bottom)
182 {
183 rectWindow.left = left; rectWindow.top = top;
184 rectWindow.right = right; rectWindow.bottom = bottom;
185 };
186 void setWindowRect(PRECT rect) { rectWindow = *rect; };
187 DWORD getFlags() { return flags; };
188 void setFlags(DWORD newflags) { flags = newflags; };
189
190 HMENU GetMenu() { return dwIDMenu; };
191 VOID SetMenu(HMENU newMenu) { dwIDMenu = newMenu; };
192 void SetSysMenu(HMENU hSystemMenu) { hSysMenu = hSystemMenu; };
193 HMENU GetSysMenu() { return hSysMenu; }
194
195 BOOL SetIcon(HICON hIcon);
196 HICON GetIcon() { return (HICON) iconResource; };
197
198 void SetWindowRegion(HRGN hRegion) { hWindowRegion = hRegion; };
199 HRGN GetWindowRegion() { return hWindowRegion; };
200 HRGN GetUpdateRegion() { return hUpdateRegion; };
201
202 BOOL ShowWindow(ULONG nCmdShow);
203 BOOL SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags);
204 BOOL SetWindowPlacement(WINDOWPLACEMENT *winpos);
205 BOOL DestroyWindow();
206 HWND SetActiveWindow();
207 HWND GetParent();
208 HWND SetParent(HWND hwndNewParent);
209
210 BOOL IsChild(HWND hwndParent);
211 HWND GetTopWindow();
212Win32BaseWindow *GetTopParent();
213 BOOL UpdateWindow();
214 BOOL IsIconic();
215 HWND GetWindow(UINT uCmd);
216 virtual BOOL EnableWindow(BOOL fEnable);
217 BOOL CloseWindow();
218 static HWND GetActiveWindow();
219 //Window handle has already been verified, so just return true
220 BOOL IsWindow() { return TRUE; };
221 BOOL IsDialog() { return fIsDialog; };
222 BOOL IsModalDialog() { return fIsModalDialog; };
223 BOOL IsModalDialogOwner() { return fIsModalDialogOwner; };
224 VOID setModalDialogOwner(BOOL fMDO) { fIsModalDialogOwner = fMDO; };
225 VOID setOS2HwndModalDialog(HWND aHwnd) { OS2HwndModalDialog = aHwnd; };
226 HWND getOS2HwndModalDialog() { return OS2HwndModalDialog; };
227 BOOL CanReceiveSizeMsgs() { return !fNoSizeMsg; };
228 BOOL IsWindowCreated() { return fCreated; }
229 BOOL IsWindowDestroyed() { return fIsDestroyed; };
230 BOOL IsWindowEnabled();
231 BOOL IsWindowVisible();
232 //Created with CreateWindowExA or ExW
233// BOOL IsUnicode() { return isUnicode; };
234 //Window procedure type
235 BOOL IsWindowUnicode();
236
237 int GetWindowTextLength();
238 int GetWindowTextA(LPSTR lpsz, int cch);
239 int GetWindowTextW(LPWSTR lpsz, int cch);
240 BOOL SetWindowTextA(LPSTR lpsz);
241 BOOL SetWindowTextW(LPWSTR lpsz);
242 BOOL hasWindowName(LPSTR wndname, BOOL fUnicode = 0);
243 CHAR *getWindowNamePtrA();
244 WCHAR *getWindowNamePtrW();
245 VOID freeWindowNamePtr(PVOID namePtr);
246 CHAR *getWindowNameA() { return windowNameA; }; //only for MDI windows!
247 WCHAR *getWindowNameW() { return windowNameW; }; //only for MDI windows!
248Win32WndClass *getClass() { return windowClass; };
249Win32BaseWindow *getOwner() { return owner; };
250 void setOwner(Win32BaseWindow *newOwner) { owner = newOwner; };
251
252 SCROLLBAR_INFO *getScrollInfo(int nBar);
253
254 LRESULT SendMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
255 LRESULT SendMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
256static LRESULT BroadcastMessageA(int type, UINT msg, WPARAM wParam, LPARAM lParam);
257static LRESULT BroadcastMessageW(int type, UINT msg, WPARAM wParam, LPARAM lParam);
258 void CallWindowHookProc(ULONG hooktype, ULONG Msg, WPARAM wParam, LPARAM lParam, BOOL fUnicode = FALSE);
259
260 LRESULT DefWindowProcA(UINT Msg, WPARAM wParam, LPARAM lParam);
261 LRESULT DefWindowProcW(UINT msg, WPARAM wParam, LPARAM lParam);
262
263 LRESULT DefWndControlColor(UINT ctlType, HDC hdc);
264 LRESULT DefWndPrint(HDC hdc,ULONG uFlags);
265
266 void NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam);
267
268Win32BaseWindow *FindWindowById(int id);
269
270 static HWND FindWindowEx(HWND hwndParent, HWND hwndChildAfter, LPSTR lpszClass, LPSTR lpszWindow,
271 BOOL fUnicode = 0);
272
273 BOOL EnumChildWindows(WNDENUMPROC lpfn, LPARAM lParam);
274 BOOL EnumThreadWindows(DWORD dwThreadId, WNDENUMPROC lpfn, LPARAM lParam);
275 BOOL EnumWindows(WNDENUMPROC lpfn, LPARAM lParam);
276
277 HWND getNextDlgTabItem(HWND hwndCtrl, BOOL fPrevious);
278 HWND getNextDlgGroupItem(HWND hwndCtrl, BOOL fPrevious);
279
280 static HWND Win32ToOS2Handle(HWND hwnd);
281 static HWND Win32ToOS2FrameHandle(HWND hwnd);
282 static HWND OS2ToWin32Handle(HWND hwnd);
283
284static Win32BaseWindow *GetWindowFromHandle(HWND hwnd);
285static Win32BaseWindow *GetWindowFromOS2Handle(HWND hwnd);
286static Win32BaseWindow *GetWindowFromOS2FrameHandle(HWND hwnd);
287
288 static void DestroyAll();
289
290 PVOID getOldFrameProc() { return pOldFrameProc; };
291 VOID setOldFrameProc(PVOID aOldFrameProc) { pOldFrameProc = aOldFrameProc; };
292
293 PVOID getOldWndProc() { return pOldWndProc; }
294 VOID setOldWndProc(PVOID aOldWndProc) { pOldWndProc = aOldWndProc; }
295
296protected:
297#ifndef OS2_INCLUDED
298 BOOL CreateWindowExA(CREATESTRUCTA *lpCreateStruct, ATOM classAtom);
299#endif
300 LRESULT SendInternalMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
301 LRESULT SendInternalMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
302 void Init();
303 void setExtendedKey(ULONG virtualkey, ULONG *lParam);
304
305 HWND OS2Hwnd;
306 HWND OS2HwndFrame;
307 HMENU hSysMenu;
308 HWND Win32Hwnd;
309 BOOL isUnicode;
310
311 int posx, posy, width, height;
312
313 // values normally contained in the standard window words
314 ULONG dwExStyle; //GWL_EXSTYLE
315 ULONG dwStyle; //GWL_STYLE
316 WNDPROC win32wndproc; //GWL_WNDPROC
317 ULONG hInstance; //GWL_HINSTANCE
318//Moved in ChildWindow class
319///// Win32BaseWindow *parent; //GWL_HWNDPARENT
320 ULONG dwIDMenu; //GWL_ID
321 ULONG userData; //GWL_USERDATA
322
323 HWND hwndLinkAfter;
324 DWORD flags;
325 DWORD contextHelpId;
326 LONG lastHitTestVal; //Last value returned by WM_NCHITTEST handler
327
328 BOOL isIcon;
329 BOOL fFirstShow;
330 BOOL fIsDialog;
331 BOOL fIsModalDialog;
332 BOOL fIsModalDialogOwner;
333 HWND OS2HwndModalDialog;
334 BOOL fInternalMsg; //Used to distinguish between messages
335 //sent by PM and those sent by apps
336 BOOL fNoSizeMsg;
337 BOOL fIsDestroyed;
338 BOOL fDestroyWindowCalled; //DestroyWindow was called for this window
339 BOOL fCreated;
340 BOOL fTaskList; //should be listed in PM tasklist or not
341 BOOL fParentDC;
342
343 HRGN hWindowRegion;
344 HRGN hUpdateRegion;
345
346 DWORD dwThreadId; //id of thread that created this window
347 DWORD dwProcessId; //id of process that created this window
348 PVOID pOldFrameProc;
349
350 PVOID pOldWndProc;
351
352 Win32BaseWindow *owner;
353 Win32Resource *iconResource;
354
355 char *windowNameA;
356 WCHAR *windowNameW;
357 ULONG wndNameLength; //including 0 terminator
358
359 ULONG *userWindowLong;
360 ULONG nrUserWindowLong;
361
362 RECT rectWindow; //relative to screen
363 RECT rectClient; //relative to parent
364
365CREATESTRUCTA *tmpcs; //temporary pointer to CREATESTRUCT used in CreateWindowEx
366 ULONG sw; //set in CreateWindowExA, used in MsgCreate method
367
368SCROLLBAR_INFO *vertScrollInfo;
369SCROLLBAR_INFO *horzScrollInfo;
370
371Win32WndClass *windowClass;
372
373static GenericObject *windows;
374
375private:
376#ifndef OS2_INCLUDED
377 void GetMinMaxInfo(POINT *maxSize, POINT *maxPos, POINT *minTrack, POINT *maxTrack );
378 LONG HandleWindowPosChanging(WINDOWPOS *winpos);
379 LONG HandleNCActivate(WPARAM wParam);
380 VOID TrackMinMaxBox(WORD wParam);
381 VOID TrackCloseButton(WORD wParam);
382 VOID TrackScrollBar(WPARAM wParam,POINT pt);
383 LONG HandleNCLButtonDown(WPARAM wParam,LPARAM lParam);
384 LONG HandleNCLButtonDblClk(WPARAM wParam,LPARAM lParam);
385 LONG HandleNCRButtonUp(WPARAM wParam,LPARAM lParam);
386 VOID AdjustRectOuter(LPRECT rect,BOOL menu);
387 VOID AdjustRectInner(LPRECT rect);
388 LONG HandleNCCalcSize(BOOL calcValidRects,RECT *winRect);
389 VOID GetInsideRect(RECT *rect);
390 VOID DrawFrame(HDC hdc,RECT *rect,BOOL dlgFrame,BOOL active);
391public:
392 LONG HandleNCHitTest(POINT pt);
393 BOOL GetSysPopupPos(RECT* rect);
394private:
395 BOOL DrawSysButton(HDC hdc,RECT *rect);
396 BOOL DrawGrayButton(HDC hdc,int x,int y);
397 VOID DrawCloseButton(HDC hdc,RECT *rect,BOOL down,BOOL bGrayed);
398 VOID DrawMaxButton(HDC hdc,RECT *rect,BOOL down,BOOL bGrayed);
399 VOID DrawMinButton(HDC hdc,RECT *rect,BOOL down,BOOL bGrayed);
400 VOID DrawCaption(HDC hdc,RECT *rect,BOOL active,BOOL redrawText);
401 VOID DoNCPaint(HRGN clip,BOOL suppress_menupaint);
402 LONG HandleNCPaint(HRGN clip);
403 LONG HandleSysCommand(WPARAM wParam, POINT *pt32);
404
405 LONG SendNCCalcSize(BOOL calcValidRect,
406 RECT *newWindowRect, RECT *oldWindowRect,
407 RECT *oldClientRect, WINDOWPOS *winpos,
408 RECT *newClientRect );
409
410 LRESULT SendInternalMessage(ULONG msg, WPARAM wParam, LPARAM lParam)
411 {
412 if(isUnicode)
413 return SendInternalMessageW(msg, wParam, lParam);
414 else return SendInternalMessageA(msg, wParam, lParam);
415 }
416#else
417friend BOOL OS2ToWinMsgTranslate(void *pThdb, QMSG *os2Msg, MSG *winMsg, BOOL isUnicode, BOOL fTranslateExtraMsgs);
418#endif
419
420public:
421 void SetFakeOpen32() { WinSetDAXData (OS2Hwnd, &fakeWinBase); }
422 void RemoveFakeOpen32() { WinSetDAXData (OS2Hwnd, NULL); }
423
424 fakeOpen32WinBaseClass fakeWinBase;
425
426 VOID AdjustMaximizedRect(LPRECT rect);
427 VOID AdjustTrackInfo(PPOINT minTrackSize,PPOINT maxTrackSize);
428
429 BOOL isOwnDC() { return (windowClass && windowClass->getStyle() & CS_OWNDC_W); }
430 HDC getOwnDC() { return ownDC; }
431 void setOwnDC(HDC hdc) { ownDC = hdc; }
432protected:
433 HDC ownDC;
434
435 ULONG EraseBkgndFlag:1,
436 PSEraseFlag:1,
437 SuppressEraseFlag:1,
438 filler:29;
439public:
440 VOID setEraseBkgnd (BOOL erase, BOOL PSErase = FALSE)
441 { EraseBkgndFlag = erase; PSEraseFlag = PSErase; }
442 VOID setSuppressErase (BOOL erase = FALSE)
443 { SuppressEraseFlag = erase; }
444 BOOL isEraseBkgnd() { return EraseBkgndFlag; }
445 BOOL isPSErase() { return EraseBkgndFlag | PSEraseFlag; }
446 BOOL isSuppressErase() { return SuppressEraseFlag; }
447};
448
449#endif //__cplusplus
450
451#endif //__WIN32WNDBASE_H__
Note: See TracBrowser for help on using the repository browser.