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

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

win32 look update

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