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

Last change on this file since 5087 was 4925, checked in by sandervl, 25 years ago

HAS_THICKFRAME change

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