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

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

compile fix

File size: 17.1 KB
Line 
1/* $Id: win32wbase.h,v 1.23 2000-01-10 23:37:24 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(ULONG x, ULONG y);
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 LONG getLastHitTestVal() { return lastHitTestVal; }
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 rect->right -= rect->left;
141 rect->bottom -= rect->top;
142 rect->left = rect->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; };
161 VOID SetMenu(HMENU newMenu) { hMenu = newMenu; };
162 void SetSysMenu(HMENU hSystemMenu) { hSysMenu = hSystemMenu; };
163 HMENU GetSysMenu() { return hSysMenu; }
164
165 BOOL SetIcon(HICON hIcon);
166 HICON GetIcon() { return (HICON) iconResource; };
167
168 void SetWindowRegion(HRGN hRegion) { hWindowRegion = hRegion; };
169 HRGN GetWindowRegion() { return hWindowRegion; };
170
171 BOOL ShowWindow(ULONG nCmdShow);
172 BOOL SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags);
173 BOOL SetWindowPlacement(WINDOWPLACEMENT *winpos);
174 BOOL DestroyWindow();
175 HWND SetActiveWindow();
176 HWND GetParent();
177 HWND SetParent(HWND hwndNewParent);
178 BOOL IsChild(HWND hwndParent);
179 HWND GetTopWindow();
180Win32BaseWindow *GetTopParent();
181 BOOL UpdateWindow();
182 BOOL IsIconic();
183 HWND GetWindow(UINT uCmd);
184 virtual BOOL EnableWindow(BOOL fEnable);
185 BOOL CloseWindow();
186 static HWND GetActiveWindow();
187 //Window handle has already been verified, so just return true
188 BOOL IsWindow() { return TRUE; };
189 BOOL IsDialog() { return fIsDialog; };
190 BOOL IsModalDialog() { return fIsModalDialog; };
191 BOOL IsModalDialogOwner() { return fIsModalDialogOwner; };
192 VOID setModalDialogOwner(BOOL fMDO) { fIsModalDialogOwner = fMDO; };
193 VOID setOS2HwndModalDialog(HWND aHwnd) { OS2HwndModalDialog = aHwnd; };
194 HWND getOS2HwndModalDialog() { return OS2HwndModalDialog; };
195 BOOL CanReceiveSizeMsgs() { return !fNoSizeMsg; };
196 BOOL IsWindowCreated() { return fCreated; }
197 BOOL IsWindowDestroyed() { return fIsDestroyed; };
198 BOOL IsWindowEnabled();
199 BOOL IsWindowVisible();
200 //Created with CreateWindowExA or ExW
201// BOOL IsUnicode() { return isUnicode; };
202 //Window procedure type
203 BOOL IsWindowUnicode();
204
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
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 ULONG getBorderWidth() { return borderWidth; };
261 ULONG getBorderHeight() { return borderHeight; };
262
263 PVOID getOldWndProc() { return pOldWndProc; }
264 VOID setOldWndProc(PVOID aOldWndProc) { pOldWndProc = aOldWndProc; }
265 BOOL isSubclassedOS2Wnd() { return fIsSubclassedOS2Wnd; };
266
267protected:
268#ifndef OS2_INCLUDED
269 BOOL CreateWindowExA(CREATESTRUCTA *lpCreateStruct, ATOM classAtom);
270#endif
271 LRESULT SendInternalMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
272 LRESULT SendInternalMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
273 void Init();
274 void setExtendedKey(ULONG virtualkey, ULONG *lParam);
275
276 HWND OS2Hwnd;
277 HWND OS2HwndFrame;
278 HMENU hMenu;
279 HMENU hSysMenu;
280 HWND Win32Hwnd;
281 BOOL isUnicode;
282
283 int posx, posy, width, height;
284
285 // values normally contained in the standard window words
286 ULONG dwExStyle; //GWL_EXSTYLE
287 ULONG dwStyle; //GWL_STYLE
288 WNDPROC win32wndproc; //GWL_WNDPROC
289 ULONG hInstance; //GWL_HINSTANCE
290//Moved in ChildWindow class
291///// Win32BaseWindow *parent; //GWL_HWNDPARENT
292 ULONG windowId; //GWL_ID
293 ULONG userData; //GWL_USERDATA
294
295 HWND hwndLinkAfter;
296 DWORD flags;
297 DWORD contextHelpId;
298 LONG lastHitTestVal; //Last value returned by WM_NCHITTEST handler
299
300 BOOL isIcon;
301 BOOL fFirstShow;
302 BOOL fIsDialog;
303 BOOL fIsModalDialog;
304 BOOL fIsModalDialogOwner;
305 HWND OS2HwndModalDialog;
306 BOOL fInternalMsg; //Used to distinguish between messages
307 //sent by PM and those sent by apps
308 BOOL fNoSizeMsg;
309 BOOL fIsDestroyed;
310 BOOL fDestroyWindowCalled; //DestroyWindow was called for this window
311 BOOL fCreated;
312 BOOL fTaskList; //should be listed in PM tasklist or not
313 BOOL fParentDC;
314
315 HRGN hWindowRegion;
316
317 DWORD dwThreadId; //id of thread that created this window
318 DWORD dwProcessId; //id of process that created this window
319 PVOID pOldFrameProc;
320 ULONG borderWidth;
321 ULONG borderHeight;
322
323 PVOID pOldWndProc;
324 BOOL fIsSubclassedOS2Wnd; //subclassed OS/2 window: Netscape plug-in/scrollbar
325
326 Win32BaseWindow *owner;
327 Win32Resource *iconResource;
328
329 char *windowNameA;
330 WCHAR *windowNameW;
331 ULONG wndNameLength; //including 0 terminator
332
333 ULONG *userWindowLong;
334 ULONG nrUserWindowLong;
335
336 RECT rectWindow; //relative to screen
337 RECT rectClient; //relative to parent
338
339CREATESTRUCTA *tmpcs; //temporary pointer to CREATESTRUCT used in CreateWindowEx
340 ULONG sw; //set in CreateWindowExA, used in MsgCreate method
341
342SCROLLBAR_INFO *vertScrollInfo;
343SCROLLBAR_INFO *horzScrollInfo;
344
345Win32WndClass *windowClass;
346
347static GenericObject *windows;
348
349private:
350#ifndef OS2_INCLUDED
351 void GetMinMaxInfo(POINT *maxSize, POINT *maxPos, POINT *minTrack, POINT *maxTrack );
352 LONG HandleWindowPosChanging(WINDOWPOS *winpos);
353 LONG HandleNCActivate(WPARAM wParam);
354 VOID TrackMinMaxBox(WORD wParam);
355 VOID TrackCloseButton(WORD wParam);
356 VOID TrackScrollBar(WPARAM wParam,POINT pt);
357 LONG HandleNCLButtonDown(WPARAM wParam,LPARAM lParam);
358 LONG HandleNCLButtonDblClk(WPARAM wParam,LPARAM lParam);
359 BOOL WindowNeedsWMBorder();
360 VOID AdjustRectOuter(LPRECT rect,BOOL menu);
361 VOID AdjustRectInner(LPRECT rect);
362 LONG HandleNCCalcSize(BOOL calcValidRects,RECT *winRect);
363 VOID GetInsideRect(RECT *rect);
364 VOID DrawFrame(HDC hdc,RECT *rect,BOOL dlgFrame,BOOL active);
365public:
366 LONG HandleNCHitTest(POINT pt);
367 BOOL DrawSysButton(HDC hdc,BOOL down);
368 BOOL GetSysPopupPos(RECT* rect);
369private:
370 BOOL DrawGrayButton(HDC hdc,int x,int y);
371 VOID DrawCloseButton(HDC hdc,BOOL down,BOOL bGrayed);
372 VOID DrawMaxButton(HDC hdc,BOOL down,BOOL bGrayed);
373 VOID DrawMinButton(HDC hdc,BOOL down,BOOL bGrayed);
374 VOID DrawCaption(HDC hdc,RECT *rect,BOOL active);
375 VOID DoNCPaint(HRGN clip,BOOL suppress_menupaint);
376 LONG HandleNCPaint(HRGN clip);
377 LONG HandleSysCommand(WPARAM wParam, POINT *pt32);
378
379 LONG SendNCCalcSize(BOOL calcValidRect,
380 RECT *newWindowRect, RECT *oldWindowRect,
381 RECT *oldClientRect, WINDOWPOS *winpos,
382 RECT *newClientRect );
383
384 LRESULT SendInternalMessage(ULONG msg, WPARAM wParam, LPARAM lParam)
385 {
386 if(isUnicode)
387 return SendInternalMessageW(msg, wParam, lParam);
388 else return SendInternalMessageA(msg, wParam, lParam);
389 }
390#else
391friend BOOL OS2ToWinMsgTranslate(void *pThdb, QMSG *os2Msg, MSG *winMsg, BOOL isUnicode, BOOL fTranslateExtraMsgs);
392#endif
393
394public:
395 void SetFakeOpen32() { WinSetDAXData (OS2Hwnd, &fakeWinBase); }
396 void RemoveFakeOpen32() { WinSetDAXData (OS2Hwnd, NULL); }
397
398 fakeOpen32WinBaseClass fakeWinBase;
399
400 BOOL isOwnDC() { return (windowClass && windowClass->getStyle() & CS_OWNDC_W); }
401 HDC getOwnDC() { return ownDC; }
402 void setOwnDC(HDC hdc) { ownDC = hdc; }
403protected:
404 HDC ownDC;
405
406 ULONG EraseBkgndFlag:1,
407 PSEraseFlag:1,
408 SuppressEraseFlag:1,
409 filler:29;
410public:
411 VOID setEraseBkgnd (BOOL erase, BOOL PSErase = FALSE)
412 { EraseBkgndFlag = erase; PSEraseFlag = PSErase; }
413 VOID setSuppressErase (BOOL erase = FALSE)
414 { SuppressEraseFlag = erase; }
415 BOOL isEraseBkgnd() { return EraseBkgndFlag; }
416 BOOL isPSErase() { return EraseBkgndFlag | PSEraseFlag; }
417 BOOL isSuppressErase() { return SuppressEraseFlag; }
418};
419
420#endif //__cplusplus
421
422#endif //__WIN32WNDBASE_H__
Note: See TracBrowser for help on using the repository browser.