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

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

WS_MAXIMIZE & WS_MINIMIZE flags updated when necessary & RedrawWindow changes

File size: 17.9 KB
Line 
1/* $Id: win32wbase.h,v 1.86 2000-02-24 19:19:10 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 HICON GetIcon() { return hIcon; }
196 HICON GetSmallIcon() { return hIconSm; }
197
198 void SetWindowRegion(HRGN hRegion) { hWindowRegion = hRegion; };
199 HRGN GetWindowRegion() { return hWindowRegion; };
200
201 //Save old clip region for CS_OWNDC windows (in BeginPaint)
202 HRGN GetClipRegion() { return hClipRegion; };
203 void SetClipRegion(HRGN hRegion) { hClipRegion = hRegion; };
204
205 BOOL ShowWindow(ULONG nCmdShow);
206 BOOL SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags);
207 BOOL SetWindowPlacement(WINDOWPLACEMENT *winpos);
208 BOOL DestroyWindow();
209 HWND SetActiveWindow();
210 HWND GetParent();
211 HWND SetParent(HWND hwndNewParent);
212
213 BOOL IsChild(HWND hwndParent);
214
215 HWND GetTopWindow();
216Win32BaseWindow *GetTopParent();
217
218 HWND GetWindow(UINT uCmd);
219 virtual BOOL EnableWindow(BOOL fEnable);
220 BOOL CloseWindow();
221 static HWND GetActiveWindow();
222 //Window handle has already been verified, so just return true
223 BOOL IsWindow() { return TRUE; };
224 BOOL IsDialog() { return fIsDialog; };
225 BOOL IsModalDialog() { return fIsModalDialog; };
226 BOOL IsModalDialogOwner() { return fIsModalDialogOwner; };
227 VOID setModalDialogOwner(BOOL fMDO) { fIsModalDialogOwner = fMDO; };
228 VOID setOS2HwndModalDialog(HWND aHwnd) { OS2HwndModalDialog = aHwnd; };
229 HWND getOS2HwndModalDialog() { return OS2HwndModalDialog; };
230 BOOL CanReceiveSizeMsgs() { return !fNoSizeMsg; };
231 BOOL IsWindowCreated() { return fCreated; }
232 BOOL IsWindowDestroyed() { return fIsDestroyed; };
233 BOOL IsWindowEnabled();
234 BOOL IsWindowVisible();
235 BOOL IsWindowIconic();
236 //Window procedure type
237 BOOL IsWindowUnicode();
238
239 int GetWindowTextLength();
240 int GetWindowTextA(LPSTR lpsz, int cch);
241 int GetWindowTextW(LPWSTR lpsz, int cch);
242 BOOL SetWindowTextA(LPSTR lpsz);
243 BOOL SetWindowTextW(LPWSTR lpsz);
244 BOOL hasWindowName(LPSTR wndname, BOOL fUnicode = 0);
245 CHAR *getWindowNamePtrA();
246 WCHAR *getWindowNamePtrW();
247 VOID freeWindowNamePtr(PVOID namePtr);
248 CHAR *getWindowNameA() { return windowNameA; }; //only for MDI windows!
249 WCHAR *getWindowNameW() { return windowNameW; }; //only for MDI windows!
250Win32WndClass *getClass() { return windowClass; };
251Win32BaseWindow *getOwner() { return owner; };
252 void setOwner(Win32BaseWindow *newOwner) { owner = newOwner; };
253
254 SCROLLBAR_INFO *getScrollInfo(int nBar);
255
256 LRESULT SendMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
257 LRESULT SendMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
258static LRESULT BroadcastMessageA(int type, UINT msg, WPARAM wParam, LPARAM lParam);
259static LRESULT BroadcastMessageW(int type, UINT msg, WPARAM wParam, LPARAM lParam);
260 void CallWindowHookProc(ULONG hooktype, ULONG Msg, WPARAM wParam, LPARAM lParam, BOOL fUnicode = FALSE);
261
262 LRESULT DefWindowProcA(UINT Msg, WPARAM wParam, LPARAM lParam);
263 LRESULT DefWindowProcW(UINT msg, WPARAM wParam, LPARAM lParam);
264
265 LRESULT DefWndControlColor(UINT ctlType, HDC hdc);
266 LRESULT DefWndPrint(HDC hdc,ULONG uFlags);
267
268 void NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam);
269
270Win32BaseWindow *FindWindowById(int id);
271
272 static HWND FindWindowEx(HWND hwndParent, HWND hwndChildAfter, LPSTR lpszClass, LPSTR lpszWindow,
273 BOOL fUnicode = 0);
274
275 BOOL EnumChildWindows(WNDENUMPROC lpfn, LPARAM lParam);
276 BOOL EnumThreadWindows(DWORD dwThreadId, WNDENUMPROC lpfn, LPARAM lParam);
277 BOOL EnumWindows(WNDENUMPROC lpfn, LPARAM lParam);
278
279 HWND getNextDlgTabItem(HWND hwndCtrl, BOOL fPrevious);
280 HWND getNextDlgGroupItem(HWND hwndCtrl, BOOL fPrevious);
281
282 static HWND Win32ToOS2Handle(HWND hwnd);
283 static HWND Win32ToOS2FrameHandle(HWND hwnd);
284 static HWND OS2ToWin32Handle(HWND hwnd);
285
286static Win32BaseWindow *GetWindowFromHandle(HWND hwnd);
287static Win32BaseWindow *GetWindowFromOS2Handle(HWND hwnd);
288static Win32BaseWindow *GetWindowFromOS2FrameHandle(HWND hwnd);
289
290 static void DestroyAll();
291
292 PVOID getOldFrameProc() { return pOldFrameProc; };
293 VOID setOldFrameProc(PVOID aOldFrameProc) { pOldFrameProc = aOldFrameProc; };
294
295 PVOID getOldWndProc() { return pOldWndProc; }
296 VOID setOldWndProc(PVOID aOldWndProc) { pOldWndProc = aOldWndProc; }
297
298protected:
299#ifndef OS2_INCLUDED
300 BOOL CreateWindowExA(CREATESTRUCTA *lpCreateStruct, ATOM classAtom);
301#endif
302 LRESULT SendInternalMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
303 LRESULT SendInternalMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
304 void Init();
305 void setExtendedKey(ULONG virtualkey, ULONG *lParam);
306
307 HWND OS2Hwnd;
308 HWND OS2HwndFrame;
309 HMENU hSysMenu;
310 HWND Win32Hwnd;
311 BOOL isUnicode;
312
313 int posx, posy, width, height;
314
315 // values normally contained in the standard window words
316 ULONG dwExStyle; //GWL_EXSTYLE
317 ULONG dwStyle; //GWL_STYLE
318 WNDPROC win32wndproc; //GWL_WNDPROC
319 ULONG hInstance; //GWL_HINSTANCE
320//Moved in ChildWindow class
321///// Win32BaseWindow *parent; //GWL_HWNDPARENT
322 ULONG dwIDMenu; //GWL_ID
323 ULONG userData; //GWL_USERDATA
324
325 HWND hwndLinkAfter;
326 DWORD flags;
327 DWORD contextHelpId;
328 DWORD hotkey;
329 LONG lastHitTestVal; //Last value returned by WM_NCHITTEST handler
330
331 BOOL fFirstShow;
332 BOOL fIsDialog;
333 BOOL fIsModalDialog;
334 BOOL fIsModalDialogOwner;
335 HWND OS2HwndModalDialog;
336 BOOL fInternalMsg; //Used to distinguish between messages
337 //sent by PM and those sent by apps
338 BOOL fNoSizeMsg;
339 BOOL fIsDestroyed;
340 BOOL fDestroyWindowCalled; //DestroyWindow was called for this window
341 BOOL fCreated;
342 BOOL fTaskList; //should be listed in PM tasklist or not
343 BOOL fXDefault;
344 BOOL fCXDefault;
345 BOOL fParentDC;
346
347 HRGN hWindowRegion;
348 HRGN hClipRegion;
349
350 DWORD dwThreadId; //id of thread that created this window
351 DWORD dwProcessId; //id of process that created this window
352 PVOID pOldFrameProc;
353
354 PVOID pOldWndProc;
355
356 Win32BaseWindow *owner;
357 HICON hIcon,hIconSm;
358
359 char *windowNameA;
360 WCHAR *windowNameW;
361 ULONG wndNameLength; //including 0 terminator
362
363 ULONG *userWindowLong;
364 ULONG nrUserWindowLong;
365
366 RECT rectWindow; //relative to screen
367 RECT rectClient; //relative to parent
368
369CREATESTRUCTA *tmpcs; //temporary pointer to CREATESTRUCT used in CreateWindowEx
370 ULONG sw; //set in CreateWindowExA, used in MsgCreate method
371
372SCROLLBAR_INFO *vertScrollInfo;
373SCROLLBAR_INFO *horzScrollInfo;
374
375Win32WndClass *windowClass;
376
377static GenericObject *windows;
378
379private:
380#ifndef OS2_INCLUDED
381 void GetMinMaxInfo(POINT *maxSize, POINT *maxPos, POINT *minTrack, POINT *maxTrack );
382 LONG HandleWindowPosChanging(WINDOWPOS *winpos);
383 LONG HandleNCActivate(WPARAM wParam);
384 VOID TrackMinMaxHelpBox(WORD wParam);
385 VOID TrackCloseButton(WORD wParam);
386 VOID TrackScrollBar(WPARAM wParam,POINT pt);
387 LONG HandleNCLButtonDown(WPARAM wParam,LPARAM lParam);
388 LONG HandleNCLButtonDblClk(WPARAM wParam,LPARAM lParam);
389 LONG HandleNCRButtonUp(WPARAM wParam,LPARAM lParam);
390 VOID AdjustRectOuter(LPRECT rect,BOOL menu);
391 VOID AdjustRectInner(LPRECT rect);
392 LONG HandleNCCalcSize(BOOL calcValidRects,RECT *winRect);
393 VOID GetInsideRect(RECT *rect);
394 VOID DrawFrame(HDC hdc,RECT *rect,BOOL dlgFrame,BOOL active);
395public:
396 LONG HandleNCHitTest(POINT pt);
397 BOOL GetSysPopupPos(RECT* rect);
398private:
399 BOOL DrawSysButton(HDC hdc,RECT *rect);
400 BOOL DrawGrayButton(HDC hdc,int x,int y);
401 VOID DrawCloseButton(HDC hdc,RECT *rect,BOOL down,BOOL bGrayed);
402 VOID DrawMaxButton(HDC hdc,RECT *rect,BOOL down,BOOL bGrayed);
403 VOID DrawMinButton(HDC hdc,RECT *rect,BOOL down,BOOL bGrayed);
404 VOID DrawContextHelpButton(HDC hdc,RECT *rect,BOOL down,BOOL bGrayed);
405 VOID DrawCaption(HDC hdc,RECT *rect,BOOL active);
406 VOID DoNCPaint(HRGN clip,BOOL suppress_menupaint);
407 LONG HandleNCPaint(HRGN clip);
408 LONG HandleSysCommand(WPARAM wParam, POINT *pt32);
409
410 LONG SendNCCalcSize(BOOL calcValidRect,
411 RECT *newWindowRect, RECT *oldWindowRect,
412 RECT *oldClientRect, WINDOWPOS *winpos,
413 RECT *newClientRect );
414
415 LRESULT SendInternalMessage(ULONG msg, WPARAM wParam, LPARAM lParam)
416 {
417 if(isUnicode)
418 return SendInternalMessageW(msg, wParam, lParam);
419 else return SendInternalMessageA(msg, wParam, lParam);
420 }
421#else
422friend BOOL OS2ToWinMsgTranslate(void *pThdb, QMSG *os2Msg, MSG *winMsg, BOOL isUnicode, BOOL fTranslateExtraMsgs);
423#endif
424
425public:
426 void SetFakeOpen32() { WinSetDAXData (OS2Hwnd, &fakeWinBase); }
427 void RemoveFakeOpen32() { WinSetDAXData (OS2Hwnd, NULL); }
428
429 fakeOpen32WinBaseClass fakeWinBase;
430
431 VOID AdjustMaximizedRect(LPRECT rect);
432 VOID AdjustTrackInfo(PPOINT minTrackSize,PPOINT maxTrackSize);
433
434 BOOL isOwnDC() { return (windowClass && windowClass->getStyle() & CS_OWNDC_W); }
435 HDC getOwnDC() { return ownDC; }
436 void setOwnDC(HDC hdc) { ownDC = hdc; }
437protected:
438 HDC ownDC;
439
440 ULONG EraseBkgndFlag:1,
441 filler:31;
442public:
443 VOID setEraseBkgnd (BOOL erase) { EraseBkgndFlag = erase; }
444 BOOL needsEraseBkgnd() { return EraseBkgndFlag; }
445};
446
447#endif //__cplusplus
448
449#endif //__WIN32WNDBASE_H__
Note: See TracBrowser for help on using the repository browser.