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

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

MsgFormat bugfix

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