source: trunk/src/user32/new/win32wbase.h@ 2316

Last change on this file since 2316 was 2312, checked in by sandervl, 26 years ago

PostThreadMessage bugfix

File size: 17.5 KB
Line 
1/* $Id: win32wbase.h,v 1.16 2000-01-03 21:37:17 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
59class Win32BaseWindow : public GenericObject, public ChildWindow
60{
61public:
62 DWORD magic;
63
64 Win32BaseWindow(DWORD objType);
65 Win32BaseWindow(HWND os2Handle,VOID* win32WndProc);
66 Win32BaseWindow(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode);
67virtual ~Win32BaseWindow();
68
69virtual ULONG MsgCreate(HWND hwndFrame, HWND hwndClient);
70 ULONG MsgQuit();
71 ULONG MsgClose();
72 ULONG MsgDestroy();
73virtual ULONG MsgEnable(BOOL fEnable);
74 ULONG MsgShow(BOOL fShow);
75 ULONG MsgPosChanging(LPARAM lp);
76 ULONG MsgPosChanged(LPARAM lp);
77virtual ULONG MsgActivate(BOOL fActivate, BOOL fMinimized, HWND hwnd);
78 ULONG MsgSetFocus(HWND hwnd);
79 ULONG MsgKillFocus(HWND hwnd);
80 ULONG MsgScroll(ULONG msg, ULONG scrollCode, ULONG scrollPos);
81 ULONG MsgButton(MSG *msg);
82 ULONG MsgMouseMove(MSG *msg);
83 ULONG MsgPaint(ULONG tmp1, BOOL select = TRUE);
84 ULONG MsgEraseBackGround(HDC hdc);
85 ULONG MsgInitMenu(MSG *msg);
86 ULONG MsgHitTest(MSG *msg);
87 ULONG MsgNCPaint();
88 ULONG DispatchMsgA(MSG *msg);
89 ULONG DispatchMsgW(MSG *msg);
90
91 ULONG MsgSetText(LPSTR lpsz, LONG cch);
92 ULONG MsgGetTextLength();
93 char *MsgGetText();
94 ULONG MsgContextMenu(ULONG x,ULONG y);
95 VOID updateWindowStyle(DWORD oldExStyle,DWORD oldStyle);
96
97virtual LONG SetWindowLongA(int index, ULONG value, BOOL fUnicode = FALSE);
98virtual ULONG GetWindowLongA(int index, BOOL fUnicode = FALSE);
99virtual WORD SetWindowWord(int index, WORD value);
100virtual WORD GetWindowWord(int index);
101
102 DWORD getStyle() { return dwStyle; };
103 void setStyle(DWORD newstyle) { dwStyle = newstyle; };
104 DWORD getExStyle() { return dwExStyle; };
105 void setExStyle(DWORD newexstyle) { dwExStyle = newexstyle; };
106 ULONG getInstance() { return hInstance; };
107 void setInstance(ULONG newinstance) { hInstance = newinstance; };
108 HWND getWindowHandle() { return Win32Hwnd; };
109 HWND getOS2WindowHandle() { return OS2Hwnd; };
110 HWND getOS2FrameWindowHandle() { return OS2HwndFrame; };
111 Win32WndClass *getWindowClass() { return windowClass; };
112
113 BOOL getIgnoreHitTest() { return fIgnoreHitTest; }
114 VOID setIgnoreHitTest(BOOL ignore) { fIgnoreHitTest = ignore; }
115
116 DWORD getWindowContextHelpId() { return contextHelpId; };
117 void setWindowContextHelpId(DWORD id){ contextHelpId = id; };
118
119 BOOL isFrameWindow();
120virtual BOOL isMDIClient();
121virtual BOOL isMDIChild();
122
123 BOOL fHasParentDC() { return fParentDC; };
124
125Win32BaseWindow *getParent();
126 void setParent(Win32BaseWindow *pwindow) { ChildWindow::SetParent((ChildWindow *)pwindow); };
127 WNDPROC getWindowProc() { return win32wndproc; };
128 void setWindowProc(WNDPROC newproc) { win32wndproc = newproc; };
129 DWORD getWindowId() { return windowId; };
130 void setWindowId(DWORD id);
131 ULONG getWindowHeight() { return rectWindow.bottom - rectWindow.top; };
132 ULONG getWindowWidth() { return rectWindow.right - rectWindow.left; };
133 ULONG getClientHeight() { return rectClient.bottom - rectClient.top; };
134 ULONG getClientWidth() { return rectClient.right - rectClient.left; };
135 BOOL isChild();
136 PRECT getClientRectPtr() { return &rectClient; };
137 void getClientRect(PRECT rect)
138 {
139 *rect = rectClient;
140 rectClient.right -= rectClient.left;
141 rectClient.bottom -= rectClient.top;
142 rectClient.left = rectClient.top = 0;
143 }
144 void setClientRect(PRECT rect) { rectClient = *rect; };
145 PRECT getWindowRect() { return &rectWindow; };
146 void setClientRect(LONG left, LONG top, LONG right, LONG bottom)
147 {
148 rectClient.left = left; rectClient.top = top;
149 rectClient.right = right; rectClient.bottom = bottom;
150 };
151 void setWindowRect(LONG left, LONG top, LONG right, LONG bottom)
152 {
153 rectWindow.left = left; rectWindow.top = top;
154 rectWindow.right = right; rectWindow.bottom = bottom;
155 };
156 void setWindowRect(PRECT rect) { rectWindow = *rect; };
157 DWORD getFlags() { return flags; };
158 void setFlags(DWORD newflags) { flags = newflags; };
159
160 HMENU GetMenu() { return (HMENU) OS2HwndMenu; };
161 BOOL SetMenu(ULONG hMenu);
162
163 BOOL SetIcon(HICON hIcon);
164 HICON GetIcon() { return (HICON) iconResource; };
165
166 void SetWindowRegion(HRGN hRegion) { hWindowRegion = hRegion; };
167 HRGN GetWindowRegion() { return hWindowRegion; };
168
169 BOOL ShowWindow(ULONG nCmdShow);
170 BOOL SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags);
171 BOOL SetWindowPlacement(WINDOWPLACEMENT *winpos);
172 BOOL DestroyWindow();
173 HWND SetActiveWindow();
174 HWND GetParent();
175 HWND SetParent(HWND hwndNewParent);
176 BOOL IsChild(HWND hwndParent);
177 HWND GetTopWindow();
178Win32BaseWindow *GetTopParent();
179 BOOL UpdateWindow();
180 BOOL IsIconic();
181 HWND GetWindow(UINT uCmd);
182 virtual BOOL EnableWindow(BOOL fEnable);
183 BOOL CloseWindow();
184 static HWND GetActiveWindow();
185 //Window handle has already been verified, so just return true
186 BOOL IsWindow() { return TRUE; };
187 BOOL IsDialog() { return fIsDialog; };
188 BOOL IsModalDialog() { return fIsModalDialog; };
189 BOOL IsModalDialogOwner() { return fIsModalDialogOwner; };
190 VOID setModalDialogOwner(BOOL fMDO) { fIsModalDialogOwner = fMDO; };
191 VOID setOS2HwndModalDialog(HWND aHwnd) { OS2HwndModalDialog = aHwnd; };
192 HWND getOS2HwndModalDialog() { return OS2HwndModalDialog; };
193 BOOL CanReceiveSizeMsgs() { return !fNoSizeMsg; };
194 BOOL IsWindowCreated() { return fCreated; }
195 BOOL IsWindowDestroyed() { return fIsDestroyed; };
196 BOOL IsWindowEnabled();
197 BOOL IsWindowVisible();
198 //Created with CreateWindowExA or ExW
199// BOOL IsUnicode() { return isUnicode; };
200 //Window procedure type
201 BOOL IsWindowUnicode();
202
203 BOOL GetWindowRect(PRECT pRect);
204 int GetWindowTextLength();
205 int GetWindowTextA(LPSTR lpsz, int cch);
206 int GetWindowTextW(LPWSTR lpsz, int cch);
207 BOOL SetWindowTextA(LPSTR lpsz);
208 BOOL SetWindowTextW(LPWSTR lpsz);
209 BOOL hasWindowName(LPSTR wndname, BOOL fUnicode = 0);
210 CHAR *getWindowNamePtrA();
211 WCHAR *getWindowNamePtrW();
212 VOID freeWindowNamePtr(PVOID namePtr);
213 CHAR *getWindowNameA() { return windowNameA; }; //only for MDI windows!
214 WCHAR *getWindowNameW() { return windowNameW; }; //only for MDI windows!
215Win32WndClass *getClass() { return windowClass; };
216Win32BaseWindow *getOwner() { return owner; };
217 void setOwner(Win32BaseWindow *newOwner) { owner = newOwner; };
218
219 SCROLLBAR_INFO *getScrollInfo(int nBar);
220 HWND getVertScrollHandle() { return hwndVertScroll; };
221 VOID setVertScrollHandle(HWND newHandle) { hwndVertScroll = newHandle; }
222 HWND getHorzScrollHandle() { return hwndHorzScroll; };
223 VOID setHorzScrollHandle(HWND newHandle) { hwndHorzScroll = newHandle; }
224 VOID subclassScrollBars(BOOL subHorz,BOOL subVert);
225 BOOL showScrollBars(BOOL changeHorz,BOOL changeVert,BOOL fShow);
226
227 LRESULT SendMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
228 LRESULT SendMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
229static LRESULT BroadcastMessageA(int type, UINT msg, WPARAM wParam, LPARAM lParam);
230static LRESULT BroadcastMessageW(int type, UINT msg, WPARAM wParam, LPARAM lParam);
231 void CallWindowHookProc(ULONG hooktype, ULONG Msg, WPARAM wParam, LPARAM lParam, BOOL fUnicode = FALSE);
232
233 LRESULT DefWindowProcA(UINT Msg, WPARAM wParam, LPARAM lParam);
234 LRESULT DefWindowProcW(UINT msg, WPARAM wParam, LPARAM lParam);
235
236 LRESULT DefWndControlColor(UINT ctlType, HDC hdc);
237 LRESULT DefWndPrint(HDC hdc,ULONG uFlags);
238
239 void NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam);
240
241Win32BaseWindow *FindWindowById(int id);
242
243 static HWND FindWindowEx(HWND hwndParent, HWND hwndChildAfter, LPSTR lpszClass, LPSTR lpszWindow,
244 BOOL fUnicode = 0);
245
246 BOOL EnumChildWindows(WNDENUMPROC lpfn, LPARAM lParam);
247 BOOL EnumThreadWindows(DWORD dwThreadId, WNDENUMPROC lpfn, LPARAM lParam);
248 BOOL EnumWindows(WNDENUMPROC lpfn, LPARAM lParam);
249
250 HWND getNextDlgTabItem(HWND hwndCtrl, BOOL fPrevious);
251 HWND getNextDlgGroupItem(HWND hwndCtrl, BOOL fPrevious);
252
253 static HWND Win32ToOS2Handle(HWND hwnd);
254 static HWND Win32ToOS2FrameHandle(HWND hwnd);
255 static HWND OS2ToWin32Handle(HWND hwnd);
256
257static Win32BaseWindow *GetWindowFromHandle(HWND hwnd);
258static Win32BaseWindow *GetWindowFromOS2Handle(HWND hwnd);
259static Win32BaseWindow *GetWindowFromOS2FrameHandle(HWND hwnd);
260
261 static void DestroyAll();
262
263 PVOID getOldFrameProc() { return pOldFrameProc; };
264 VOID setOldFrameProc(PVOID aOldFrameProc) { pOldFrameProc = aOldFrameProc; };
265 ULONG getBorderWidth() { return borderWidth; };
266 ULONG getBorderHeight() { return borderHeight; };
267
268 PVOID getOldWndProc() { return pOldWndProc; }
269 VOID setOldWndProc(PVOID aOldWndProc) { pOldWndProc = aOldWndProc; }
270 BOOL isSubclassedOS2Wnd() { return fIsSubclassedOS2Wnd; };
271
272protected:
273#ifndef OS2_INCLUDED
274 BOOL CreateWindowExA(CREATESTRUCTA *lpCreateStruct, ATOM classAtom);
275#endif
276 LRESULT SendInternalMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
277 LRESULT SendInternalMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
278 void Init();
279 void setExtendedKey(ULONG virtualkey, ULONG *lParam);
280
281 HWND OS2Hwnd;
282 HWND OS2HwndFrame;
283 HWND OS2HwndMenu;
284 HWND Win32Hwnd;
285 BOOL isUnicode;
286
287 int posx, posy, width, height;
288
289 // values normally contained in the standard window words
290 ULONG dwExStyle; //GWL_EXSTYLE
291 ULONG dwStyle; //GWL_STYLE
292 WNDPROC win32wndproc; //GWL_WNDPROC
293 ULONG hInstance; //GWL_HINSTANCE
294//Moved in ChildWindow class
295///// Win32BaseWindow *parent; //GWL_HWNDPARENT
296 ULONG windowId; //GWL_ID
297 ULONG userData; //GWL_USERDATA
298
299 HWND hwndLinkAfter;
300 DWORD flags;
301 DWORD contextHelpId;
302 LONG lastHitTestVal; //Last value returned by WM_NCHITTEST handler
303 BOOL fIgnoreHitTest; //Use WinWindowFromPoint during WM_HITTEST
304
305 BOOL isIcon;
306 BOOL fFirstShow;
307 BOOL fIsDialog;
308 BOOL fIsModalDialog;
309 BOOL fIsModalDialogOwner;
310 HWND OS2HwndModalDialog;
311 BOOL fInternalMsg; //Used to distinguish between messages
312 //sent by PM and those sent by apps
313 BOOL fNoSizeMsg;
314 BOOL fIsDestroyed;
315 BOOL fDestroyWindowCalled; //DestroyWindow was called for this window
316 BOOL fCreated;
317 BOOL fTaskList; //should be listed in PM tasklist or not
318 BOOL fParentDC;
319
320 HRGN hWindowRegion;
321
322 DWORD dwThreadId; //id of thread that created this window
323 DWORD dwProcessId; //id of process that created this window
324 PVOID pOldFrameProc;
325 ULONG borderWidth;
326 ULONG borderHeight;
327
328 PVOID pOldWndProc;
329 BOOL fIsSubclassedOS2Wnd; //subclassed OS/2 window: Netscape plug-in/scrollbar
330
331 Win32BaseWindow *owner;
332 Win32Resource *iconResource;
333
334 char *windowNameA;
335 WCHAR *windowNameW;
336 ULONG wndNameLength; //including 0 terminator
337
338 ULONG *userWindowLong;
339 ULONG nrUserWindowLong;
340
341 RECT rectWindow; //relative to screen
342 RECT rectClient; //relative to parent
343
344CREATESTRUCTA *tmpcs; //temporary pointer to CREATESTRUCT used in CreateWindowEx
345 ULONG sw; //set in CreateWindowExA, used in MsgCreate method
346
347SCROLLBAR_INFO *vertScrollInfo;
348SCROLLBAR_INFO *horzScrollInfo;
349 HWND hwndHorzScroll; //os/2 handle
350 HWND hwndVertScroll; //os/2 handle
351
352Win32WndClass *windowClass;
353
354static GenericObject *windows;
355
356private:
357#ifndef OS2_INCLUDED
358 void GetMinMaxInfo(POINT *maxSize, POINT *maxPos, POINT *minTrack, POINT *maxTrack );
359 LONG HandleWindowPosChanging(WINDOWPOS *winpos);
360 LONG HandleNCActivate(WPARAM wParam);
361 VOID TrackMinMaxBox(WORD wParam);
362 VOID TrackCloseButton(WORD wParam);
363 LONG HandleNCLButtonDown(WPARAM wParam,LPARAM lParam);
364 LONG HandleNCLButtonUp(WPARAM wParam,LPARAM lParam);
365 LONG HandleNCLButtonDblClk(WPARAM wParam,LPARAM lParam);
366 BOOL WindowNeedsWMBorder();
367 VOID AdjustRectOuter(LPRECT rect,BOOL menu);
368 VOID AdjustRectInner(LPRECT rect);
369 LONG HandleNCCalcSize(RECT *winRect);
370 LONG HandleNCHitTest(POINT pt);
371 VOID GetInsideRect(RECT *rect);
372 VOID DrawFrame(HDC hdc,RECT *rect,BOOL dlgFrame,BOOL active);
373 BOOL DrawSysButton(HDC hdc,BOOL down);
374 BOOL DrawGrayButton(HDC hdc,int x,int y);
375 VOID DrawCloseButton(HDC hdc,BOOL down,BOOL bGrayed);
376 VOID DrawMaxButton(HDC hdc,BOOL down,BOOL bGrayed);
377 VOID DrawMinButton(HDC hdc,BOOL down,BOOL bGrayed);
378 VOID DrawCaption(HDC hdc,RECT *rect,BOOL active);
379 VOID DoNCPaint(HRGN clip,BOOL suppress_menupaint);
380 LONG HandleNCPaint(HRGN clip);
381 LONG HandleSysCommand(WPARAM wParam, POINT *pt32);
382
383 LONG SendNCCalcSize(BOOL calcValidRect,
384 RECT *newWindowRect, RECT *oldWindowRect,
385 RECT *oldClientRect, WINDOWPOS *winpos,
386 RECT *newClientRect );
387
388 LRESULT SendInternalMessage(ULONG msg, WPARAM wParam, LPARAM lParam)
389 {
390 if(isUnicode)
391 return SendInternalMessageW(msg, wParam, lParam);
392 else return SendInternalMessageA(msg, wParam, lParam);
393 }
394#else
395friend BOOL OS2ToWinMsgTranslate(void *pThdb, QMSG *os2Msg, MSG *winMsg, BOOL isUnicode, BOOL fTranslateExtraMsgs);
396#endif
397
398public:
399 void SetFakeOpen32() { WinSetDAXData (OS2Hwnd, &fakeWinBase); }
400 void RemoveFakeOpen32() { WinSetDAXData (OS2Hwnd, NULL); }
401
402 fakeOpen32WinBaseClass fakeWinBase;
403
404 BOOL isOwnDC() { return (windowClass && windowClass->getStyle() & CS_OWNDC_W); }
405 HDC getOwnDC() { return ownDC; }
406 void setOwnDC(HDC hdc) { ownDC = hdc; }
407protected:
408 HDC ownDC;
409
410 ULONG EraseBkgndFlag:1,
411 PSEraseFlag:1,
412 SuppressEraseFlag:1,
413 filler:29;
414public:
415 VOID setEraseBkgnd (BOOL erase, BOOL PSErase = FALSE)
416 { EraseBkgndFlag = erase; PSEraseFlag = PSErase; }
417 VOID setSuppressErase (BOOL erase = FALSE)
418 { SuppressEraseFlag = erase; }
419 BOOL isEraseBkgnd() { return EraseBkgndFlag; }
420 BOOL isPSErase() { return EraseBkgndFlag | PSEraseFlag; }
421 BOOL isSuppressErase() { return SuppressEraseFlag; }
422};
423
424#endif //__cplusplus
425
426#endif //__WIN32WNDBASE_H__
Note: See TracBrowser for help on using the repository browser.