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

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

* empty log message *

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