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

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

OSLibGetMsg bugfix + WM_QUIT translation fix

File size: 17.2 KB
Line 
1/* $Id: win32wbase.h,v 1.67 2000-01-08 14:15:09 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 BOOL getDefWndProcCalled() { return fDefWndProcCalled; };
117 void clearDefWndProcCalled() { fDefWndProcCalled = 0; };
118
119 DWORD getWindowContextHelpId() { return contextHelpId; };
120 void setWindowContextHelpId(DWORD id){ contextHelpId = id; };
121
122 BOOL isFrameWindow();
123virtual BOOL isMDIClient();
124virtual BOOL isMDIChild();
125
126 BOOL fHasParentDC() { return fParentDC; };
127
128Win32BaseWindow *getParent();
129 void setParent(Win32BaseWindow *pwindow) { ChildWindow::SetParent((ChildWindow *)pwindow); };
130 WNDPROC getWindowProc() { return win32wndproc; };
131 void setWindowProc(WNDPROC newproc) { win32wndproc = newproc; };
132 DWORD getWindowId() { return windowId; };
133 void setWindowId(DWORD id);
134 ULONG getWindowHeight() { return rectWindow.bottom - rectWindow.top; };
135 ULONG getWindowWidth() { return rectWindow.right - rectWindow.left; };
136 ULONG getClientHeight() { return rectClient.bottom - rectClient.top; };
137 ULONG getClientWidth() { return rectClient.right - rectClient.left; };
138 BOOL isChild();
139 PRECT getClientRect() { return &rectClient; };
140 void setClientRect(PRECT rect) { rectClient = *rect; };
141 PRECT getWindowRect() { return &rectWindow; };
142 void setClientRect(LONG left, LONG top, LONG right, LONG bottom)
143 {
144 rectClient.left = left; rectClient.top = top;
145 rectClient.right = right; rectClient.bottom = bottom;
146 };
147 void setWindowRect(LONG left, LONG top, LONG right, LONG bottom)
148 {
149 rectWindow.left = left; rectWindow.top = top;
150 rectWindow.right = right; rectWindow.bottom = bottom;
151 };
152 void setWindowRect(PRECT rect) { rectWindow = *rect; };
153 DWORD getFlags() { return flags; };
154 void setFlags(DWORD newflags) { flags = newflags; };
155
156 HMENU GetMenu() { return (HMENU) OS2HwndMenu; };
157 BOOL SetMenu(ULONG hMenu);
158
159 BOOL SetIcon(HICON hIcon);
160 HICON GetIcon() { return (HICON) iconResource; };
161
162 void SetWindowRegion(HRGN hRegion) { hWindowRegion = hRegion; };
163 HRGN GetWindowRegion() { return hWindowRegion; };
164
165 BOOL ShowWindow(ULONG nCmdShow);
166 BOOL SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags);
167 BOOL SetWindowPlacement(WINDOWPLACEMENT *winpos);
168 BOOL DestroyWindow();
169 HWND SetActiveWindow();
170 HWND GetParent();
171 HWND SetParent(HWND hwndNewParent);
172 BOOL IsChild(HWND hwndParent);
173 HWND GetTopWindow();
174Win32BaseWindow *GetTopParent();
175 BOOL UpdateWindow();
176 BOOL IsIconic();
177 HWND GetWindow(UINT uCmd);
178 virtual BOOL EnableWindow(BOOL fEnable);
179 BOOL CloseWindow();
180 static HWND GetActiveWindow();
181 //Window handle has already been verified, so just return true
182 BOOL IsWindow() { return TRUE; };
183 BOOL IsDialog() { return fIsDialog; };
184 BOOL IsModalDialog() { return fIsModalDialog; };
185 BOOL IsModalDialogOwner() { return fIsModalDialogOwner; };
186 VOID setModalDialogOwner(BOOL fMDO) { fIsModalDialogOwner = fMDO; };
187 VOID setOS2HwndModalDialog(HWND aHwnd) { OS2HwndModalDialog = aHwnd; };
188 HWND getOS2HwndModalDialog() { return OS2HwndModalDialog; };
189 BOOL CanReceiveSizeMsgs() { return !fNoSizeMsg; };
190 BOOL IsWindowDestroyed() { return fIsDestroyed; };
191 BOOL IsWindowEnabled();
192 BOOL IsWindowVisible();
193 //Created with CreateWindowExA or ExW
194// BOOL IsUnicode() { return isUnicode; };
195 //Window procedure type
196 BOOL IsWindowUnicode();
197
198 BOOL GetWindowRect(PRECT pRect);
199 int GetWindowTextLength();
200 int GetWindowTextA(LPSTR lpsz, int cch);
201 int GetWindowTextW(LPWSTR lpsz, int cch);
202 BOOL SetWindowTextA(LPSTR lpsz);
203 BOOL SetWindowTextW(LPWSTR lpsz);
204 BOOL hasWindowName(LPSTR wndname, BOOL fUnicode = 0);
205 CHAR *getWindowNamePtrA();
206 WCHAR *getWindowNamePtrW();
207 VOID freeWindowNamePtr(PVOID namePtr);
208 CHAR *getWindowNameA() { return windowNameA; }; //only for MDI windows!
209 WCHAR *getWindowNameW() { return windowNameW; }; //only for MDI windows!
210Win32WndClass *getClass() { return windowClass; };
211Win32BaseWindow *getOwner() { return owner; };
212 void setOwner(Win32BaseWindow *newOwner) { owner = newOwner; };
213
214 SCROLLBAR_INFO *getScrollInfo(int nBar);
215 HWND getVertScrollHandle() { return hwndVertScroll; };
216 VOID setVertScrollHandle(HWND newHandle) { hwndVertScroll = newHandle; }
217 HWND getHorzScrollHandle() { return hwndHorzScroll; };
218 VOID setHorzScrollHandle(HWND newHandle) { hwndHorzScroll = newHandle; }
219 VOID subclassScrollBars(BOOL subHorz,BOOL subVert);
220 BOOL showScrollBars(BOOL changeHorz,BOOL changeVert,BOOL fShow);
221
222 LRESULT SendMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
223 LRESULT SendMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
224static LRESULT BroadcastMessageA(int type, UINT msg, WPARAM wParam, LPARAM lParam);
225static LRESULT BroadcastMessageW(int type, UINT msg, WPARAM wParam, LPARAM lParam);
226 void CallWindowHookProc(ULONG hooktype, ULONG Msg, WPARAM wParam, LPARAM lParam, BOOL fUnicode = FALSE);
227
228 LRESULT DefWindowProcA(UINT Msg, WPARAM wParam, LPARAM lParam);
229 LRESULT DefWindowProcW(UINT msg, WPARAM wParam, LPARAM lParam);
230
231 LRESULT DefWndControlColor(UINT ctlType, HDC hdc);
232 LRESULT DefWndPrint(HDC hdc,ULONG uFlags);
233
234 void NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam);
235
236Win32BaseWindow *FindWindowById(int id);
237
238 static HWND FindWindowEx(HWND hwndParent, HWND hwndChildAfter, LPSTR lpszClass, LPSTR lpszWindow,
239 BOOL fUnicode = 0);
240
241 BOOL EnumChildWindows(WNDENUMPROC lpfn, LPARAM lParam);
242 BOOL EnumThreadWindows(DWORD dwThreadId, WNDENUMPROC lpfn, LPARAM lParam);
243 BOOL EnumWindows(WNDENUMPROC lpfn, LPARAM lParam);
244
245 HWND getNextDlgTabItem(HWND hwndCtrl, BOOL fPrevious);
246 HWND getNextDlgGroupItem(HWND hwndCtrl, BOOL fPrevious);
247
248 static HWND Win32ToOS2Handle(HWND hwnd);
249 static HWND Win32ToOS2FrameHandle(HWND hwnd);
250 static HWND OS2ToWin32Handle(HWND hwnd);
251
252static Win32BaseWindow *GetWindowFromHandle(HWND hwnd);
253static Win32BaseWindow *GetWindowFromOS2Handle(HWND hwnd);
254static Win32BaseWindow *GetWindowFromOS2FrameHandle(HWND hwnd);
255
256 static void DestroyAll();
257
258 PVOID getOldFrameProc() { return pOldFrameProc; };
259 VOID setOldFrameProc(PVOID aOldFrameProc) { pOldFrameProc = aOldFrameProc; };
260 PVOID getOldTitleBarProc() { return pOldTitleBarProc; };
261 VOID setOldTitleBarProc(PVOID aOldTitleBarProc) { pOldTitleBarProc = aOldTitleBarProc; };
262 PVOID getOldMenuProc() { return pOldMenuProc; };
263 VOID setOldMenuProc(PVOID aOldMenuProc) { pOldMenuProc = aOldMenuProc; };
264 ULONG getBorderWidth() { return borderWidth; };
265 ULONG getBorderHeight() { return borderHeight; };
266
267static void NC_AdjustRectInner(LPRECT rect, DWORD style, DWORD exStyle);
268static void NC_AdjustRectOuter(LPRECT rect, DWORD style, BOOL menu, DWORD exStyle);
269static BOOL WindowNeedsWMBorder( DWORD style, DWORD exStyle );
270
271 PVOID getOldWndProc() { return pOldWndProc; }
272 VOID setOldWndProc(PVOID aOldWndProc) { pOldWndProc = aOldWndProc; }
273 BOOL isSubclassedOS2Wnd() { return fIsSubclassedOS2Wnd; };
274
275protected:
276#ifndef OS2_INCLUDED
277 BOOL CreateWindowExA(CREATESTRUCTA *lpCreateStruct, ATOM classAtom);
278#endif
279 LRESULT SendInternalMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
280 LRESULT SendInternalMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
281 void Init();
282 void setExtendedKey(ULONG virtualkey, ULONG *lParam);
283
284 HWND OS2Hwnd;
285 HWND OS2HwndFrame;
286 HWND OS2HwndMenu;
287 HWND Win32Hwnd;
288 BOOL isUnicode;
289
290 int posx, posy, width, height;
291
292 // values normally contained in the standard window words
293 ULONG dwExStyle; //GWL_EXSTYLE
294 ULONG dwStyle; //GWL_STYLE
295 WNDPROC win32wndproc; //GWL_WNDPROC
296 ULONG hInstance; //GWL_HINSTANCE
297//Moved in ChildWindow class
298///// Win32BaseWindow *parent; //GWL_HWNDPARENT
299 ULONG windowId; //GWL_ID
300 ULONG userData; //GWL_USERDATA
301
302 HWND hwndLinkAfter;
303 DWORD flags;
304 DWORD contextHelpId;
305 LONG lastHitTestVal; //Last value returned by WM_NCHITTEST handler
306 BOOL fIgnoreHitTest; //Use WinWindowFromPoint during WM_HITTEST
307
308 BOOL isIcon;
309 BOOL fFirstShow;
310 BOOL fIsDialog;
311 BOOL fIsModalDialog;
312 BOOL fIsModalDialogOwner;
313 HWND OS2HwndModalDialog;
314 BOOL fInternalMsg; //Used to distinguish between messages
315 //sent by PM and those sent by apps
316 BOOL fNoSizeMsg;
317 BOOL fIsDestroyed;
318 BOOL fDestroyWindowCalled; //DestroyWindow was called for this window
319 BOOL fCreated;
320 BOOL fTaskList; //should be listed in PM tasklist or not
321 BOOL fParentDC;
322
323 BOOL fDefWndProcCalled; //set when DefWndProc called; used in PM window handlers to determine what to do next
324
325 HRGN hWindowRegion;
326
327 DWORD dwThreadId; //id of thread that created this window
328 DWORD dwProcessId; //id of process that created this window
329 PVOID pOldFrameProc;
330 PVOID pOldTitleBarProc;
331 PVOID pOldMenuProc;
332 ULONG borderWidth;
333 ULONG borderHeight;
334
335 PVOID pOldWndProc;
336 BOOL fIsSubclassedOS2Wnd; //subclassed OS/2 window: Netscape plug-in/scrollbar
337
338 Win32BaseWindow *owner;
339 Win32Resource *iconResource;
340
341 char *windowNameA;
342 WCHAR *windowNameW;
343 ULONG wndNameLength; //including 0 terminator
344
345 ULONG *userWindowLong;
346 ULONG nrUserWindowLong;
347
348 RECT rectWindow;
349 RECT rectClient;
350
351CREATESTRUCTA *tmpcs; //temporary pointer to CREATESTRUCT used in CreateWindowEx
352 ULONG sw; //set in CreateWindowExA, used in MsgCreate method
353
354SCROLLBAR_INFO *vertScrollInfo;
355SCROLLBAR_INFO *horzScrollInfo;
356 HWND hwndHorzScroll; //os/2 handle
357 HWND hwndVertScroll; //os/2 handle
358
359Win32WndClass *windowClass;
360
361static GenericObject *windows;
362
363private:
364#ifndef OS2_INCLUDED
365 void GetMinMaxInfo(POINT *maxSize, POINT *maxPos, POINT *minTrack, POINT *maxTrack );
366 LONG HandleWindowPosChanging(WINDOWPOS *winpos);
367 LONG HandleNCLButtonDown(WPARAM wParam,LPARAM lParam);
368 LONG HandleNCLButtonUp(WPARAM wParam,LPARAM lParam);
369 LONG HandleNCLButtonDblClk(WPARAM wParam,LPARAM lParam);
370 LONG HandleSysCommand(WPARAM wParam, POINT *pt32);
371
372 LONG SendNCCalcSize(BOOL calcValidRect,
373 RECT *newWindowRect, RECT *oldWindowRect,
374 RECT *oldClientRect, WINDOWPOS *winpos,
375 RECT *newClientRect );
376
377 LONG NCHandleCalcSize(WPARAM wParam, NCCALCSIZE_PARAMS *ncsize);
378
379 LRESULT SendInternalMessage(ULONG msg, WPARAM wParam, LPARAM lParam)
380 {
381 if(isUnicode)
382 return SendInternalMessageW(msg, wParam, lParam);
383 else return SendInternalMessageA(msg, wParam, lParam);
384 }
385#else
386friend BOOL OS2ToWinMsgTranslate(void *pThdb, QMSG *os2Msg, MSG *winMsg, BOOL isUnicode, BOOL fTranslateExtraMsgs);
387#endif
388
389public:
390 void SetFakeOpen32() { WinSetDAXData (OS2Hwnd, &fakeWinBase); }
391 void RemoveFakeOpen32() { WinSetDAXData (OS2Hwnd, NULL); }
392
393 fakeOpen32WinBaseClass fakeWinBase;
394
395 BOOL isOwnDC() { return (windowClass && windowClass->getStyle() & CS_OWNDC_W); }
396 HDC getOwnDC() { return ownDC; }
397 void setOwnDC(HDC hdc) { ownDC = hdc; }
398protected:
399 HDC ownDC;
400
401 ULONG EraseBkgndFlag:1,
402 PSEraseFlag:1,
403 SuppressEraseFlag:1,
404 filler:29;
405public:
406 VOID setEraseBkgnd (BOOL erase, BOOL PSErase = FALSE)
407 { EraseBkgndFlag = erase; PSEraseFlag = PSErase; }
408 VOID setSuppressErase (BOOL erase = FALSE)
409 { SuppressEraseFlag = erase; }
410 BOOL isEraseBkgnd() { return EraseBkgndFlag; }
411 BOOL isPSErase() { return EraseBkgndFlag | PSEraseFlag; }
412 BOOL isSuppressErase() { return SuppressEraseFlag; }
413};
414
415#endif //__cplusplus
416
417#endif //__WIN32WNDBASE_H__
Note: See TracBrowser for help on using the repository browser.