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

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

merged with Corel WINE 20000212, added WS_EX_CONTEXTHELP

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