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

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

non-client fixes, DefWndProc enhancements, several other bugs fixed

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