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

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

BvL: Added accelerator support

File size: 15.8 KB
Line 
1/* $Id: win32wbase.h,v 1.61 1999-12-30 09:31:03 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#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 HWND getWindowHandle() { return Win32Hwnd; };
104 HWND getOS2WindowHandle() { return OS2Hwnd; };
105 HWND getOS2FrameWindowHandle() { return OS2HwndFrame; };
106 Win32WndClass *getWindowClass() { return windowClass; };
107
108 BOOL getIgnoreHitTest() { return fIgnoreHitTest; }
109 VOID setIgnoreHitTest(BOOL ignore) { fIgnoreHitTest = ignore; }
110
111 DWORD getWindowContextHelpId() { return contextHelpId; };
112 void setWindowContextHelpId(DWORD id){ contextHelpId = id; };
113
114 BOOL isFrameWindow();
115virtual BOOL isMDIClient();
116virtual BOOL isMDIChild();
117
118 BOOL fHasParentDC() { return fParentDC; };
119
120Win32BaseWindow *getParent();
121 void setParent(Win32BaseWindow *pwindow) { ChildWindow::SetParent((ChildWindow *)pwindow); };
122 WNDPROC getWindowProc() { return win32wndproc; };
123 void setWindowProc(WNDPROC newproc) { win32wndproc = newproc; };
124 DWORD getWindowId() { return windowId; };
125 void setWindowId(DWORD id);
126 ULONG getWindowHeight() { return rectWindow.bottom - rectWindow.top; };
127 ULONG getWindowWidth() { return rectWindow.right - rectWindow.left; };
128 ULONG getClientHeight() { return rectClient.bottom - rectClient.top; };
129 ULONG getClientWidth() { return rectClient.right - rectClient.left; };
130 BOOL isChild();
131 PRECT getClientRect() { return &rectClient; };
132 void setClientRect(PRECT rect) { rectClient = *rect; };
133 PRECT getWindowRect() { return &rectWindow; };
134 void setClientRect(LONG left, LONG top, LONG right, LONG bottom)
135 {
136 rectClient.left = left; rectClient.top = top;
137 rectClient.right = right; rectClient.bottom = bottom;
138 };
139 void setWindowRect(LONG left, LONG top, LONG right, LONG bottom)
140 {
141 rectWindow.left = left; rectWindow.top = top;
142 rectWindow.right = right; rectWindow.bottom = bottom;
143 };
144 void setWindowRect(PRECT rect) { rectWindow = *rect; };
145 DWORD getFlags() { return flags; };
146 void setFlags(DWORD newflags) { flags = newflags; };
147
148 HMENU GetMenu() { return (HMENU) OS2HwndMenu; };
149 BOOL SetMenu(ULONG hMenu);
150
151 BOOL SetIcon(HICON hIcon);
152 HICON GetIcon() { return (HICON) iconResource; };
153
154 BOOL ShowWindow(ULONG nCmdShow);
155 BOOL SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags);
156 BOOL SetWindowPlacement(WINDOWPLACEMENT *winpos);
157 BOOL DestroyWindow();
158 HWND SetActiveWindow();
159 HWND GetParent();
160 HWND SetParent(HWND hwndNewParent);
161 BOOL IsChild(HWND hwndParent);
162 HWND GetTopWindow();
163Win32BaseWindow *GetTopParent();
164 BOOL UpdateWindow();
165 BOOL IsIconic();
166 HWND GetWindow(UINT uCmd);
167 virtual BOOL EnableWindow(BOOL fEnable);
168 BOOL CloseWindow();
169 static HWND GetActiveWindow();
170 //Window handle has already been verified, so just return true
171 BOOL IsWindow() { return TRUE; };
172 BOOL IsDialog() { return fIsDialog; };
173 BOOL IsModalDialog() { return fIsModalDialog; };
174 BOOL IsModalDialogOwner() { return fIsModalDialogOwner; };
175 VOID setModalDialogOwner(BOOL fMDO) { fIsModalDialogOwner = fMDO; };
176 VOID setOS2HwndModalDialog(HWND aHwnd) { OS2HwndModalDialog = aHwnd; };
177 HWND getOS2HwndModalDialog() { return OS2HwndModalDialog; };
178 BOOL CanReceiveSizeMsgs() { return !fNoSizeMsg; };
179 BOOL IsWindowDestroyed() { return fIsDestroyed; };
180 BOOL IsWindowEnabled();
181 BOOL IsWindowVisible();
182 //Created with CreateWindowExA or ExW
183// BOOL IsUnicode() { return isUnicode; };
184 //Window procedure type
185 BOOL IsWindowUnicode();
186
187 BOOL GetWindowRect(PRECT pRect);
188 int GetWindowTextLength();
189 int GetWindowTextA(LPSTR lpsz, int cch);
190 int GetWindowTextW(LPWSTR lpsz, int cch);
191 BOOL SetWindowTextA(LPSTR lpsz);
192 BOOL SetWindowTextW(LPWSTR lpsz);
193 BOOL hasWindowName(LPSTR wndname, BOOL fUnicode = 0);
194Win32WndClass *getClass() { return windowClass; };
195 char *getWindowNameA() { return windowNameA; };
196Win32BaseWindow *getOwner() { return owner; };
197
198 SCROLLBAR_INFO *getScrollInfo(int nBar);
199 HWND getVertScrollHandle() { return hwndVertScroll; };
200 VOID setVertScrollHandle(HWND newHandle) { hwndVertScroll = newHandle; }
201 HWND getHorzScrollHandle() { return hwndHorzScroll; };
202 VOID setHorzScrollHandle(HWND newHandle) { hwndHorzScroll = newHandle; }
203 VOID subclassScrollBars(BOOL subHorz,BOOL subVert);
204 BOOL showScrollBars(BOOL changeHorz,BOOL changeVert,BOOL fShow);
205
206 LRESULT SendMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
207 LRESULT SendMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
208static LRESULT BroadcastMessageA(int type, UINT msg, WPARAM wParam, LPARAM lParam);
209static LRESULT BroadcastMessageW(int type, UINT msg, WPARAM wParam, LPARAM lParam);
210 void CallWindowHookProc(ULONG hooktype, ULONG Msg, WPARAM wParam, LPARAM lParam, BOOL fUnicode = FALSE);
211
212 LRESULT DefWindowProcA(UINT Msg, WPARAM wParam, LPARAM lParam);
213 LRESULT DefWindowProcW(UINT msg, WPARAM wParam, LPARAM lParam);
214
215 LRESULT DefWndControlColor(UINT ctlType, HDC hdc);
216 LRESULT DefWndPrint(HDC hdc,ULONG uFlags);
217
218 void NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam);
219
220Win32BaseWindow *FindWindowById(int id);
221
222 static HWND FindWindowEx(HWND hwndParent, HWND hwndChildAfter, LPSTR lpszClass, LPSTR lpszWindow,
223 BOOL fUnicode = 0);
224
225 BOOL EnumChildWindows(WNDENUMPROC lpfn, LPARAM lParam);
226 BOOL EnumThreadWindows(DWORD dwThreadId, WNDENUMPROC lpfn, LPARAM lParam);
227 BOOL EnumWindows(WNDENUMPROC lpfn, LPARAM lParam);
228
229 HWND getNextDlgTabItem(HWND hwndCtrl, BOOL fPrevious);
230 HWND getNextDlgGroupItem(HWND hwndCtrl, BOOL fPrevious);
231
232 static HWND Win32ToOS2Handle(HWND hwnd);
233 static HWND Win32ToOS2FrameHandle(HWND hwnd);
234 static HWND OS2ToWin32Handle(HWND hwnd);
235
236static Win32BaseWindow *GetWindowFromHandle(HWND hwnd);
237static Win32BaseWindow *GetWindowFromOS2Handle(HWND hwnd);
238static Win32BaseWindow *GetWindowFromOS2FrameHandle(HWND hwnd);
239
240 static void DestroyAll();
241
242 PVOID getOldFrameProc() { return pOldFrameProc; };
243 VOID setOldFrameProc(PVOID aOldFrameProc) { pOldFrameProc = aOldFrameProc; };
244 ULONG getBorderWidth() { return borderWidth; };
245 ULONG getBorderHeight() { return borderHeight; };
246
247static void NC_AdjustRectInner(LPRECT rect, DWORD style, DWORD exStyle);
248static void NC_AdjustRectOuter(LPRECT rect, DWORD style, BOOL menu, DWORD exStyle);
249static BOOL WindowNeedsWMBorder( DWORD style, DWORD exStyle );
250
251 PVOID getOldWndProc() { return pOldWndProc; }
252 VOID setOldWndProc(PVOID aOldWndProc) { pOldWndProc = aOldWndProc; }
253 BOOL isSubclassedOS2Wnd() { return fIsSubclassedOS2Wnd; };
254
255protected:
256#ifndef OS2_INCLUDED
257 BOOL CreateWindowExA(CREATESTRUCTA *lpCreateStruct, ATOM classAtom);
258#endif
259 LRESULT SendInternalMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
260 LRESULT SendInternalMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
261 void Init();
262 void setExtendedKey(ULONG virtualkey, ULONG *lParam);
263
264 HWND OS2Hwnd;
265 HWND OS2HwndFrame;
266 HWND OS2HwndMenu;
267 HWND Win32Hwnd;
268 BOOL isUnicode;
269
270 int posx, posy, width, height;
271
272 // values normally contained in the standard window words
273 ULONG dwExStyle; //GWL_EXSTYLE
274 ULONG dwStyle; //GWL_STYLE
275 WNDPROC win32wndproc; //GWL_WNDPROC
276 ULONG hInstance; //GWL_HINSTANCE
277//Moved in ChildWindow class
278///// Win32BaseWindow *parent; //GWL_HWNDPARENT
279 ULONG windowId; //GWL_ID
280 ULONG userData; //GWL_USERDATA
281
282 HWND hwndLinkAfter;
283 DWORD flags;
284 DWORD contextHelpId;
285 LONG lastHitTestVal; //Last value returned by WM_NCHITTEST handler
286 BOOL fIgnoreHitTest; //Use WinWindowFromPoint during WM_HITTEST
287
288 BOOL isIcon;
289 BOOL fFirstShow;
290 BOOL fIsDialog;
291 BOOL fIsModalDialog;
292 BOOL fIsModalDialogOwner;
293 HWND OS2HwndModalDialog;
294 BOOL fInternalMsg; //Used to distinguish between messages
295 //sent by PM and those sent by apps
296 BOOL fNoSizeMsg;
297 BOOL fIsDestroyed;
298 BOOL fDestroyWindowCalled; //DestroyWindow was called for this window
299 BOOL fCreated;
300 BOOL fTaskList; //should be listed in PM tasklist or not
301 BOOL fParentDC;
302
303 DWORD dwThreadId; //id of thread that created this window
304 DWORD dwProcessId; //id of process that created this window
305 PVOID pOldFrameProc;
306 ULONG borderWidth;
307 ULONG borderHeight;
308
309 PVOID pOldWndProc;
310 BOOL fIsSubclassedOS2Wnd; //subclassed OS/2 window: Netscape plug-in/scrollbar
311
312 Win32BaseWindow *owner;
313 Win32Resource *iconResource;
314
315 char *windowNameA;
316 WCHAR *windowNameW;
317 ULONG wndNameLength; //including 0 terminator
318
319 ULONG *userWindowLong;
320 ULONG nrUserWindowLong;
321
322 RECT rectWindow;
323 RECT rectClient;
324
325CREATESTRUCTA *tmpcs; //temporary pointer to CREATESTRUCT used in CreateWindowEx
326 ULONG sw; //set in CreateWindowExA, used in MsgCreate method
327
328SCROLLBAR_INFO *vertScrollInfo;
329SCROLLBAR_INFO *horzScrollInfo;
330 HWND hwndHorzScroll; //os/2 handle
331 HWND hwndVertScroll; //os/2 handle
332
333Win32WndClass *windowClass;
334
335static GenericObject *windows;
336
337private:
338#ifndef OS2_INCLUDED
339 void GetMinMaxInfo(POINT *maxSize, POINT *maxPos, POINT *minTrack, POINT *maxTrack );
340 LONG HandleWindowPosChanging(WINDOWPOS *winpos);
341 LONG HandleNCLButtonDown(WPARAM wParam,LPARAM lParam);
342 LONG HandleNCLButtonUp(WPARAM wParam,LPARAM lParam);
343 LONG HandleNCLButtonDblClk(WPARAM wParam,LPARAM lParam);
344 LONG HandleSysCommand(WPARAM wParam, POINT *pt32);
345
346 LONG SendNCCalcSize(BOOL calcValidRect,
347 RECT *newWindowRect, RECT *oldWindowRect,
348 RECT *oldClientRect, WINDOWPOS *winpos,
349 RECT *newClientRect );
350
351 LONG NCHandleCalcSize(WPARAM wParam, NCCALCSIZE_PARAMS *ncsize);
352
353 LRESULT SendInternalMessage(ULONG msg, WPARAM wParam, LPARAM lParam)
354 {
355 if(isUnicode)
356 return SendInternalMessageW(msg, wParam, lParam);
357 else return SendInternalMessageA(msg, wParam, lParam);
358 }
359#else
360friend BOOL OS2ToWinMsgTranslate(void *pThdb, QMSG *os2Msg, MSG *winMsg, BOOL isUnicode, BOOL fTranslateExtraMsgs);
361#endif
362
363public:
364 void SetFakeOpen32() { WinSetDAXData (OS2Hwnd, &fakeWinBase); }
365 void RemoveFakeOpen32() { WinSetDAXData (OS2Hwnd, NULL); }
366
367 fakeOpen32WinBaseClass fakeWinBase;
368
369 BOOL isOwnDC() { return (windowClass && windowClass->getStyle() & CS_OWNDC_W); }
370 HDC getOwnDC() { return ownDC; }
371 void setOwnDC(HDC hdc) { ownDC = hdc; }
372protected:
373 HDC ownDC;
374
375 ULONG EraseBkgndFlag:1,
376 PSEraseFlag:1,
377 SuppressEraseFlag:1,
378 filler:29;
379public:
380 VOID setEraseBkgnd (BOOL erase, BOOL PSErase = FALSE)
381 { EraseBkgndFlag = erase; PSEraseFlag = PSErase; }
382 VOID setSuppressErase (BOOL erase = FALSE)
383 { SuppressEraseFlag = erase; }
384 BOOL isEraseBkgnd() { return EraseBkgndFlag; }
385 BOOL isPSErase() { return EraseBkgndFlag | PSEraseFlag; }
386 BOOL isSuppressErase() { return SuppressEraseFlag; }
387};
388
389#endif //__cplusplus
390
391#endif //__WIN32WNDBASE_H__
Note: See TracBrowser for help on using the repository browser.