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

Last change on this file since 2521 was 2521, checked in by cbratschi, 26 years ago

refixed WM_WINDOWPOS*

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