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

Last change on this file since 4802 was 4628, checked in by sandervl, 25 years ago

SetWindowPos fixes for SWP_FRAMECHANGED

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