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

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

* empty log message *

File size: 17.5 KB
Line 
1/* $Id: win32wbase.h,v 1.18 2000-01-07 17:38:48 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
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 MsgFormatFrame();
89 ULONG DispatchMsgA(MSG *msg);
90 ULONG DispatchMsgW(MSG *msg);
91
92 ULONG MsgSetText(LPSTR lpsz, LONG cch);
93 ULONG MsgGetTextLength();
94 char *MsgGetText();
95 ULONG MsgContextMenu(ULONG x,ULONG y);
96 VOID updateWindowStyle(DWORD oldExStyle,DWORD oldStyle);
97
98virtual LONG SetWindowLongA(int index, ULONG value, BOOL fUnicode = FALSE);
99virtual ULONG GetWindowLongA(int index, BOOL fUnicode = FALSE);
100virtual WORD SetWindowWord(int index, WORD value);
101virtual WORD GetWindowWord(int index);
102
103 DWORD getStyle() { return dwStyle; };
104 void setStyle(DWORD newstyle) { dwStyle = newstyle; };
105 DWORD getExStyle() { return dwExStyle; };
106 void setExStyle(DWORD newexstyle) { dwExStyle = newexstyle; };
107 ULONG getInstance() { return hInstance; };
108 void setInstance(ULONG newinstance) { hInstance = newinstance; };
109 HWND getWindowHandle() { return Win32Hwnd; };
110 HWND getOS2WindowHandle() { return OS2Hwnd; };
111 HWND getOS2FrameWindowHandle() { return OS2HwndFrame; };
112 Win32WndClass *getWindowClass() { return windowClass; };
113
114 BOOL getIgnoreHitTest() { return fIgnoreHitTest; }
115 VOID setIgnoreHitTest(BOOL ignore) { fIgnoreHitTest = ignore; }
116
117 DWORD getWindowContextHelpId() { return contextHelpId; };
118 void setWindowContextHelpId(DWORD id){ contextHelpId = id; };
119
120 BOOL isFrameWindow();
121virtual BOOL isMDIClient();
122virtual BOOL isMDIChild();
123
124 BOOL fHasParentDC() { return fParentDC; };
125
126Win32BaseWindow *getParent();
127 void setParent(Win32BaseWindow *pwindow) { ChildWindow::SetParent((ChildWindow *)pwindow); };
128 WNDPROC getWindowProc() { return win32wndproc; };
129 void setWindowProc(WNDPROC newproc) { win32wndproc = newproc; };
130 DWORD getWindowId() { return windowId; };
131 void setWindowId(DWORD id);
132 ULONG getWindowHeight() { return rectWindow.bottom - rectWindow.top; };
133 ULONG getWindowWidth() { return rectWindow.right - rectWindow.left; };
134 ULONG getClientHeight() { return rectClient.bottom - rectClient.top; };
135 ULONG getClientWidth() { return rectClient.right - rectClient.left; };
136 BOOL isChild();
137 PRECT getClientRectPtr() { return &rectClient; };
138 void getClientRect(PRECT rect)
139 {
140 *rect = rectClient;
141 rect->right -= rect->left;
142 rect->bottom -= rect->top;
143 rect->left = rect->top = 0;
144 }
145 void setClientRect(PRECT rect) { rectClient = *rect; };
146 PRECT getWindowRect() { return &rectWindow; };
147 void setClientRect(LONG left, LONG top, LONG right, LONG bottom)
148 {
149 rectClient.left = left; rectClient.top = top;
150 rectClient.right = right; rectClient.bottom = bottom;
151 };
152 void setWindowRect(LONG left, LONG top, LONG right, LONG bottom)
153 {
154 rectWindow.left = left; rectWindow.top = top;
155 rectWindow.right = right; rectWindow.bottom = bottom;
156 };
157 void setWindowRect(PRECT rect) { rectWindow = *rect; };
158 DWORD getFlags() { return flags; };
159 void setFlags(DWORD newflags) { flags = newflags; };
160
161 HMENU GetMenu() { return (HMENU) OS2HwndMenu; };
162 BOOL SetMenu(ULONG hMenu);
163
164 BOOL SetIcon(HICON hIcon);
165 HICON GetIcon() { return (HICON) iconResource; };
166
167 void SetWindowRegion(HRGN hRegion) { hWindowRegion = hRegion; };
168 HRGN GetWindowRegion() { return hWindowRegion; };
169
170 BOOL ShowWindow(ULONG nCmdShow);
171 BOOL SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags);
172 BOOL SetWindowPlacement(WINDOWPLACEMENT *winpos);
173 BOOL DestroyWindow();
174 HWND SetActiveWindow();
175 HWND GetParent();
176 HWND SetParent(HWND hwndNewParent);
177 BOOL IsChild(HWND hwndParent);
178 HWND GetTopWindow();
179Win32BaseWindow *GetTopParent();
180 BOOL UpdateWindow();
181 BOOL IsIconic();
182 HWND GetWindow(UINT uCmd);
183 virtual BOOL EnableWindow(BOOL fEnable);
184 BOOL CloseWindow();
185 static HWND GetActiveWindow();
186 //Window handle has already been verified, so just return true
187 BOOL IsWindow() { return TRUE; };
188 BOOL IsDialog() { return fIsDialog; };
189 BOOL IsModalDialog() { return fIsModalDialog; };
190 BOOL IsModalDialogOwner() { return fIsModalDialogOwner; };
191 VOID setModalDialogOwner(BOOL fMDO) { fIsModalDialogOwner = fMDO; };
192 VOID setOS2HwndModalDialog(HWND aHwnd) { OS2HwndModalDialog = aHwnd; };
193 HWND getOS2HwndModalDialog() { return OS2HwndModalDialog; };
194 BOOL CanReceiveSizeMsgs() { return !fNoSizeMsg; };
195 BOOL IsWindowCreated() { return fCreated; }
196 BOOL IsWindowDestroyed() { return fIsDestroyed; };
197 BOOL IsWindowEnabled();
198 BOOL IsWindowVisible();
199 //Created with CreateWindowExA or ExW
200// BOOL IsUnicode() { return isUnicode; };
201 //Window procedure type
202 BOOL IsWindowUnicode();
203
204 BOOL GetWindowRect(PRECT pRect);
205 int GetWindowTextLength();
206 int GetWindowTextA(LPSTR lpsz, int cch);
207 int GetWindowTextW(LPWSTR lpsz, int cch);
208 BOOL SetWindowTextA(LPSTR lpsz);
209 BOOL SetWindowTextW(LPWSTR lpsz);
210 BOOL hasWindowName(LPSTR wndname, BOOL fUnicode = 0);
211 CHAR *getWindowNamePtrA();
212 WCHAR *getWindowNamePtrW();
213 VOID freeWindowNamePtr(PVOID namePtr);
214 CHAR *getWindowNameA() { return windowNameA; }; //only for MDI windows!
215 WCHAR *getWindowNameW() { return windowNameW; }; //only for MDI windows!
216Win32WndClass *getClass() { return windowClass; };
217Win32BaseWindow *getOwner() { return owner; };
218 void setOwner(Win32BaseWindow *newOwner) { owner = newOwner; };
219
220 SCROLLBAR_INFO *getScrollInfo(int nBar);
221 HWND getVertScrollHandle() { return hwndVertScroll; };
222 VOID setVertScrollHandle(HWND newHandle) { hwndVertScroll = newHandle; }
223 HWND getHorzScrollHandle() { return hwndHorzScroll; };
224 VOID setHorzScrollHandle(HWND newHandle) { hwndHorzScroll = newHandle; }
225 VOID subclassScrollBars(BOOL subHorz,BOOL subVert);
226 BOOL showScrollBars(BOOL changeHorz,BOOL changeVert,BOOL fShow);
227
228 LRESULT SendMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
229 LRESULT SendMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
230static LRESULT BroadcastMessageA(int type, UINT msg, WPARAM wParam, LPARAM lParam);
231static LRESULT BroadcastMessageW(int type, UINT msg, WPARAM wParam, LPARAM lParam);
232 void CallWindowHookProc(ULONG hooktype, ULONG Msg, WPARAM wParam, LPARAM lParam, BOOL fUnicode = FALSE);
233
234 LRESULT DefWindowProcA(UINT Msg, WPARAM wParam, LPARAM lParam);
235 LRESULT DefWindowProcW(UINT msg, WPARAM wParam, LPARAM lParam);
236
237 LRESULT DefWndControlColor(UINT ctlType, HDC hdc);
238 LRESULT DefWndPrint(HDC hdc,ULONG uFlags);
239
240 void NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam);
241
242Win32BaseWindow *FindWindowById(int id);
243
244 static HWND FindWindowEx(HWND hwndParent, HWND hwndChildAfter, LPSTR lpszClass, LPSTR lpszWindow,
245 BOOL fUnicode = 0);
246
247 BOOL EnumChildWindows(WNDENUMPROC lpfn, LPARAM lParam);
248 BOOL EnumThreadWindows(DWORD dwThreadId, WNDENUMPROC lpfn, LPARAM lParam);
249 BOOL EnumWindows(WNDENUMPROC lpfn, LPARAM lParam);
250
251 HWND getNextDlgTabItem(HWND hwndCtrl, BOOL fPrevious);
252 HWND getNextDlgGroupItem(HWND hwndCtrl, BOOL fPrevious);
253
254 static HWND Win32ToOS2Handle(HWND hwnd);
255 static HWND Win32ToOS2FrameHandle(HWND hwnd);
256 static HWND OS2ToWin32Handle(HWND hwnd);
257
258static Win32BaseWindow *GetWindowFromHandle(HWND hwnd);
259static Win32BaseWindow *GetWindowFromOS2Handle(HWND hwnd);
260static Win32BaseWindow *GetWindowFromOS2FrameHandle(HWND hwnd);
261
262 static void DestroyAll();
263
264 PVOID getOldFrameProc() { return pOldFrameProc; };
265 VOID setOldFrameProc(PVOID aOldFrameProc) { pOldFrameProc = aOldFrameProc; };
266 ULONG getBorderWidth() { return borderWidth; };
267 ULONG getBorderHeight() { return borderHeight; };
268
269 PVOID getOldWndProc() { return pOldWndProc; }
270 VOID setOldWndProc(PVOID aOldWndProc) { pOldWndProc = aOldWndProc; }
271 BOOL isSubclassedOS2Wnd() { return fIsSubclassedOS2Wnd; };
272
273protected:
274#ifndef OS2_INCLUDED
275 BOOL CreateWindowExA(CREATESTRUCTA *lpCreateStruct, ATOM classAtom);
276#endif
277 LRESULT SendInternalMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
278 LRESULT SendInternalMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
279 void Init();
280 void setExtendedKey(ULONG virtualkey, ULONG *lParam);
281
282 HWND OS2Hwnd;
283 HWND OS2HwndFrame;
284 HWND OS2HwndMenu;
285 HWND Win32Hwnd;
286 BOOL isUnicode;
287
288 int posx, posy, width, height;
289
290 // values normally contained in the standard window words
291 ULONG dwExStyle; //GWL_EXSTYLE
292 ULONG dwStyle; //GWL_STYLE
293 WNDPROC win32wndproc; //GWL_WNDPROC
294 ULONG hInstance; //GWL_HINSTANCE
295//Moved in ChildWindow class
296///// Win32BaseWindow *parent; //GWL_HWNDPARENT
297 ULONG windowId; //GWL_ID
298 ULONG userData; //GWL_USERDATA
299
300 HWND hwndLinkAfter;
301 DWORD flags;
302 DWORD contextHelpId;
303 LONG lastHitTestVal; //Last value returned by WM_NCHITTEST handler
304 BOOL fIgnoreHitTest; //Use WinWindowFromPoint during WM_HITTEST
305
306 BOOL isIcon;
307 BOOL fFirstShow;
308 BOOL fIsDialog;
309 BOOL fIsModalDialog;
310 BOOL fIsModalDialogOwner;
311 HWND OS2HwndModalDialog;
312 BOOL fInternalMsg; //Used to distinguish between messages
313 //sent by PM and those sent by apps
314 BOOL fNoSizeMsg;
315 BOOL fIsDestroyed;
316 BOOL fDestroyWindowCalled; //DestroyWindow was called for this window
317 BOOL fCreated;
318 BOOL fTaskList; //should be listed in PM tasklist or not
319 BOOL fParentDC;
320
321 HRGN hWindowRegion;
322
323 DWORD dwThreadId; //id of thread that created this window
324 DWORD dwProcessId; //id of process that created this window
325 PVOID pOldFrameProc;
326 ULONG borderWidth;
327 ULONG borderHeight;
328
329 PVOID pOldWndProc;
330 BOOL fIsSubclassedOS2Wnd; //subclassed OS/2 window: Netscape plug-in/scrollbar
331
332 Win32BaseWindow *owner;
333 Win32Resource *iconResource;
334
335 char *windowNameA;
336 WCHAR *windowNameW;
337 ULONG wndNameLength; //including 0 terminator
338
339 ULONG *userWindowLong;
340 ULONG nrUserWindowLong;
341
342 RECT rectWindow; //relative to screen
343 RECT rectClient; //relative to parent
344
345CREATESTRUCTA *tmpcs; //temporary pointer to CREATESTRUCT used in CreateWindowEx
346 ULONG sw; //set in CreateWindowExA, used in MsgCreate method
347
348SCROLLBAR_INFO *vertScrollInfo;
349SCROLLBAR_INFO *horzScrollInfo;
350 HWND hwndHorzScroll; //os/2 handle
351 HWND hwndVertScroll; //os/2 handle
352
353Win32WndClass *windowClass;
354
355static GenericObject *windows;
356
357private:
358#ifndef OS2_INCLUDED
359 void GetMinMaxInfo(POINT *maxSize, POINT *maxPos, POINT *minTrack, POINT *maxTrack );
360 LONG HandleWindowPosChanging(WINDOWPOS *winpos);
361 LONG HandleNCActivate(WPARAM wParam);
362 VOID TrackMinMaxBox(WORD wParam);
363 VOID TrackCloseButton(WORD wParam);
364 LONG HandleNCLButtonDown(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(BOOL calcValidRects,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.