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

Last change on this file since 3313 was 3284, checked in by cbratschi, 25 years ago

HTTRANSPARENT

File size: 17.7 KB
Line 
1/* $Id: win32wbase.h,v 1.91 2000-03-31 14:42:49 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 <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
40//PostThreadMessage is done through Open32; which means the message id will be translated
41//(0xc00 added)
42#define OPEN32_MSGDIFF 0xC00
43#define WIN32APP_POSTMSG (0x1000+OPEN32_MSGDIFF)
44
45#define WIN32MSG_MAGICA 0x12345678
46#define WIN32MSG_MAGICW 0x12345679
47
48typedef struct
49{
50 ULONG Msg;
51 ULONG wParam;
52 ULONG lParam;
53} POSTMSG_PACKET;
54
55#define BROADCAST_SEND 0
56#define BROADCAST_POST 1
57
58#define HAS_DLGFRAME(style,exStyle) \
59 (((exStyle) & WS_EX_DLGMODALFRAME) || \
60 (((style) & WS_DLGFRAME) && !((style) & WS_THICKFRAME)))
61
62#define HAS_THICKFRAME(style,exStyle) \
63 (((style) & WS_THICKFRAME) && \
64 !((exStyle) & WS_EX_DLGMODALFRAME) && \
65 !((style) & WS_CHILD))
66
67#define HAS_THINFRAME(style) \
68 (((style) & WS_BORDER) || !((style) & (WS_CHILD | WS_POPUP)))
69
70#define HAS_BIGFRAME(style,exStyle) \
71 (((style) & (WS_THICKFRAME | WS_DLGFRAME)) || \
72 ((exStyle) & WS_EX_DLGMODALFRAME))
73
74#define HAS_ANYFRAME(style,exStyle) \
75 (((style) & (WS_THICKFRAME | WS_DLGFRAME | WS_BORDER)) || \
76 ((exStyle) & WS_EX_DLGMODALFRAME) || \
77 !((style) & (WS_CHILD | WS_POPUP)))
78
79#define HAS_3DFRAME(exStyle) \
80 ((exStyle & WS_EX_CLIENTEDGE) || (exStyle & WS_EX_STATICEDGE) || (exStyle & WS_EX_WINDOWEDGE))
81
82#define HAS_BORDER(style, exStyle) \
83 ((style & WS_BORDER) || HAS_THICKFRAME(style) || HAS_DLGFRAME(style,exStyle))
84
85#define IS_OVERLAPPED(style) \
86 !(style & (WS_CHILD | WS_POPUP))
87
88#define HAS_MENU() (!(getStyle() & WS_CHILD) && (GetMenu() != 0))
89
90class Win32BaseWindow : public GenericObject, public ChildWindow
91{
92public:
93 DWORD magic;
94
95 Win32BaseWindow(DWORD objType);
96 Win32BaseWindow(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode);
97virtual ~Win32BaseWindow();
98
99virtual ULONG MsgCreate(HWND hwndFrame, HWND hwndClient);
100 ULONG MsgQuit();
101 ULONG MsgClose();
102 ULONG MsgDestroy();
103virtual ULONG MsgEnable(BOOL fEnable);
104 ULONG MsgShow(BOOL fShow);
105 ULONG MsgPosChanging(LPARAM lp);
106 ULONG MsgPosChanged(LPARAM lp);
107 ULONG MsgActivate(BOOL fActivate, BOOL fMinimized, HWND hwnd, HWND hwndOS2Win);
108 ULONG MsgSetFocus(HWND hwnd);
109 ULONG MsgKillFocus(HWND hwnd);
110 ULONG MsgScroll(ULONG msg, ULONG scrollCode, ULONG scrollPos);
111 ULONG MsgButton(MSG *msg);
112 ULONG MsgMouseMove(MSG *msg);
113 ULONG MsgChar(MSG *msg);
114 ULONG MsgPaint(ULONG tmp1, BOOL select = TRUE);
115 ULONG MsgEraseBackGround(HDC hdc);
116 ULONG MsgHitTest(MSG *msg);
117 ULONG MsgNCPaint();
118 ULONG MsgFormatFrame(WINDOWPOS *lpWndPos);
119 ULONG DispatchMsgA(MSG *msg);
120 ULONG DispatchMsgW(MSG *msg);
121
122 ULONG MsgSetText(LPSTR lpsz, LONG cch);
123 ULONG MsgGetTextLength();
124 void MsgGetText(char *wndtext, ULONG textlength);
125 VOID updateWindowStyle(DWORD oldExStyle,DWORD oldStyle);
126
127virtual LONG SetWindowLongA(int index, ULONG value, BOOL fUnicode = FALSE);
128virtual ULONG GetWindowLongA(int index, BOOL fUnicode = FALSE);
129virtual WORD SetWindowWord(int index, WORD value);
130virtual WORD GetWindowWord(int index);
131
132 DWORD getStyle() { return dwStyle; };
133 void setStyle(DWORD newstyle) { dwStyle = newstyle; };
134 DWORD getExStyle() { return dwExStyle; };
135 void setExStyle(DWORD newexstyle) { dwExStyle = newexstyle; };
136 ULONG getInstance() { return hInstance; };
137 void setInstance(ULONG newinstance) { hInstance = newinstance; };
138 HWND getWindowHandle() { return Win32Hwnd; };
139 HWND getOS2WindowHandle() { return OS2Hwnd; };
140 HWND getOS2FrameWindowHandle() { return OS2HwndFrame; };
141 Win32WndClass *getWindowClass() { return windowClass; };
142
143 LONG getLastHitTestVal() { return lastHitTestVal; }
144
145 DWORD getWindowContextHelpId() { return contextHelpId; };
146 void setWindowContextHelpId(DWORD id){ contextHelpId = id; };
147
148 BOOL isFrameWindow();
149virtual BOOL isMDIClient();
150virtual BOOL isMDIChild();
151
152 BOOL fHasParentDC() { return fParentDC; };
153
154Win32BaseWindow *getParent();
155 void setParent(Win32BaseWindow *pwindow) { ChildWindow::SetParent((ChildWindow *)pwindow); };
156 WNDPROC getWindowProc() { return win32wndproc; };
157 void setWindowProc(WNDPROC newproc) { win32wndproc = newproc; };
158 DWORD getWindowId() { return dwIDMenu; };
159 void setWindowId(DWORD id);
160 ULONG getWindowHeight() { return rectWindow.bottom - rectWindow.top; };
161 ULONG getWindowWidth() { return rectWindow.right - rectWindow.left; };
162 ULONG getClientHeight() { return rectClient.bottom - rectClient.top; };
163 ULONG getClientWidth() { return rectClient.right - rectClient.left; };
164 BOOL isChild();
165 PRECT getClientRectPtr() { return &rectClient; };
166 void getClientRect(PRECT rect)
167 {
168 *rect = rectClient;
169 rect->right -= rect->left;
170 rect->bottom -= rect->top;
171 rect->left = rect->top = 0;
172 }
173 void setClientRect(PRECT rect) { rectClient = *rect; };
174 PRECT getWindowRect() { return &rectWindow; };
175 void setClientRect(LONG left, LONG top, LONG right, LONG bottom)
176 {
177 rectClient.left = left; rectClient.top = top;
178 rectClient.right = right; rectClient.bottom = bottom;
179 };
180 void setWindowRect(LONG left, LONG top, LONG right, LONG bottom)
181 {
182 rectWindow.left = left; rectWindow.top = top;
183 rectWindow.right = right; rectWindow.bottom = bottom;
184 };
185 void setWindowRect(PRECT rect) { rectWindow = *rect; };
186 DWORD getFlags() { return flags; };
187 void setFlags(DWORD newflags) { flags = newflags; };
188
189 HMENU GetMenu() { return dwIDMenu; };
190 VOID SetMenu(HMENU newMenu) { dwIDMenu = newMenu; };
191 void SetSysMenu(HMENU hSystemMenu) { hSysMenu = hSystemMenu; };
192 HMENU GetSysMenu() { return hSysMenu; }
193
194 HICON IconForWindow(WPARAM fType);
195
196 void SetWindowRegion(HRGN hRegion) { hWindowRegion = hRegion; };
197 HRGN GetWindowRegion() { return hWindowRegion; };
198
199 //Save old clip region for CS_OWNDC windows (in BeginPaint)
200 HRGN GetClipRegion() { return hClipRegion; };
201 void SetClipRegion(HRGN hRegion) { hClipRegion = hRegion; };
202
203 BOOL ShowWindow(ULONG nCmdShow);
204 BOOL SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags);
205 BOOL SetWindowPlacement(WINDOWPLACEMENT *winpos);
206 BOOL DestroyWindow();
207 HWND SetActiveWindow();
208 HWND GetParent();
209 HWND SetParent(HWND hwndNewParent);
210
211 BOOL IsChild(HWND hwndParent);
212
213 HWND GetTopWindow();
214Win32BaseWindow *GetTopParent();
215
216 HWND GetWindow(UINT uCmd);
217 virtual BOOL EnableWindow(BOOL fEnable);
218 BOOL CloseWindow();
219 static HWND GetActiveWindow();
220 //Window handle has already been verified, so just return true
221 BOOL IsWindow() { return TRUE; };
222 BOOL IsDialog() { return fIsDialog; };
223 BOOL IsModalDialog() { return fIsModalDialog; };
224 BOOL IsModalDialogOwner() { return fIsModalDialogOwner; };
225 VOID setModalDialogOwner(BOOL fMDO) { fIsModalDialogOwner = fMDO; };
226 VOID setOS2HwndModalDialog(HWND aHwnd) { OS2HwndModalDialog = aHwnd; };
227 HWND getOS2HwndModalDialog() { return OS2HwndModalDialog; };
228 BOOL CanReceiveSizeMsgs() { return !fNoSizeMsg; };
229 BOOL IsWindowCreated() { return fCreated; }
230 BOOL IsWindowDestroyed() { return fIsDestroyed; };
231 BOOL IsWindowEnabled();
232 BOOL IsWindowVisible();
233 BOOL IsWindowIconic();
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, ATOM atom, LPSTR lpszWindow);
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
292 PVOID getOldWndProc() { return pOldWndProc; }
293 VOID setOldWndProc(PVOID aOldWndProc) { pOldWndProc = aOldWndProc; }
294
295protected:
296#ifndef OS2_INCLUDED
297 BOOL CreateWindowExA(CREATESTRUCTA *lpCreateStruct, ATOM classAtom);
298#endif
299 LRESULT SendInternalMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
300 LRESULT SendInternalMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
301 void Init();
302
303 HWND OS2Hwnd;
304 HWND OS2HwndFrame;
305 HMENU hSysMenu;
306 HWND Win32Hwnd;
307 BOOL isUnicode;
308
309 int posx, posy, width, height;
310
311 // values normally contained in the standard window words
312 ULONG dwExStyle; //GWL_EXSTYLE
313 ULONG dwStyle; //GWL_STYLE
314 WNDPROC win32wndproc; //GWL_WNDPROC
315 ULONG hInstance; //GWL_HINSTANCE
316//Moved in ChildWindow class
317///// Win32BaseWindow *parent; //GWL_HWNDPARENT
318 ULONG dwIDMenu; //GWL_ID
319 ULONG userData; //GWL_USERDATA
320
321 HWND hwndLinkAfter;
322 DWORD flags;
323 DWORD contextHelpId;
324 DWORD hotkey;
325 LONG lastHitTestVal; //Last value returned by WM_NCHITTEST handler
326
327 BOOL fFirstShow;
328 BOOL fIsDialog;
329 BOOL fIsModalDialog;
330 BOOL fIsModalDialogOwner;
331 HWND OS2HwndModalDialog;
332 BOOL fInternalMsg; //Used to distinguish between messages
333 //sent by PM and those sent by apps
334 BOOL fNoSizeMsg;
335 BOOL fIsDestroyed;
336 BOOL fDestroyWindowCalled; //DestroyWindow was called for this window
337 BOOL fCreated;
338 BOOL fTaskList; //should be listed in PM tasklist or not
339 BOOL fXDefault;
340 BOOL fCXDefault;
341 BOOL fParentDC;
342
343 HRGN hWindowRegion;
344 HRGN hClipRegion;
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 HICON hIcon,hIconSm;
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 TrackMinMaxHelpBox(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 DrawContextHelpButton(HDC hdc,RECT *rect,BOOL down,BOOL bGrayed);
401 VOID DrawCaption(HDC hdc,RECT *rect,BOOL active);
402 VOID DoNCPaint(HRGN clip,BOOL suppress_menupaint);
403 LONG HandleNCPaint(HRGN clip);
404 LONG HandleSysCommand(WPARAM wParam, POINT *pt32);
405
406 LONG SendNCCalcSize(BOOL calcValidRect,
407 RECT *newWindowRect, RECT *oldWindowRect,
408 RECT *oldClientRect, WINDOWPOS *winpos,
409 RECT *newClientRect );
410
411 LRESULT SendInternalMessage(ULONG msg, WPARAM wParam, LPARAM lParam)
412 {
413 if(isUnicode)
414 return SendInternalMessageW(msg, wParam, lParam);
415 else return SendInternalMessageA(msg, wParam, lParam);
416 }
417#else
418friend BOOL OS2ToWinMsgTranslate(void *pThdb, QMSG *os2Msg, MSG *winMsg, BOOL isUnicode, BOOL fTranslateExtraMsgs);
419#endif
420
421public:
422 void SetFakeOpen32() { WinSetDAXData (OS2Hwnd, &fakeWinBase); }
423 void RemoveFakeOpen32() { WinSetDAXData (OS2Hwnd, NULL); }
424
425 fakeOpen32WinBaseClass fakeWinBase;
426
427 VOID AdjustMaximizedRect(LPRECT rect);
428 VOID AdjustTrackInfo(PPOINT minTrackSize,PPOINT maxTrackSize);
429
430#ifndef OS2_INCLUDED
431 BOOL isOwnDC() { return (windowClass && windowClass->getStyle() & CS_OWNDC); }
432#else
433 BOOL isOwnDC() { return (windowClass && windowClass->getStyle() & CS_OWNDC_W); }
434#endif
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.