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

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

MDI changes + WM_INITMENU support added + disabled experimental support for CS_PARENTDC style

File size: 16.7 KB
Line 
1/* $Id: win32wbase.h,v 1.53 1999-12-14 19:13:20 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 0x6666
43
44typedef struct
45{
46 ULONG Msg;
47 ULONG wParam;
48 ULONG lParam;
49 ULONG fUnicode;
50} POSTMSG_PACKET;
51
52#define WM_WIN32_POSTMESSAGEA 0x4000
53#define WM_WIN32_POSTMESSAGEW 0x4001
54
55#define BROADCAST_SEND 0
56#define BROADCAST_POST 1
57
58class Win32BaseWindow : public GenericObject, public ChildWindow
59{
60public:
61 DWORD magic;
62
63 Win32BaseWindow(DWORD objType);
64 Win32BaseWindow(HWND os2Handle,VOID* win32WndProc);
65 Win32BaseWindow(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode);
66virtual ~Win32BaseWindow();
67
68virtual ULONG MsgCreate(HWND hwndFrame, HWND hwndClient);
69 ULONG MsgQuit();
70 ULONG MsgClose();
71 ULONG MsgDestroy();
72virtual ULONG MsgEnable(BOOL fEnable);
73 ULONG MsgShow(BOOL fShow);
74 ULONG MsgPosChanging(LPARAM lp);
75 ULONG MsgPosChanged(LPARAM lp);
76 ULONG MsgMove(ULONG x, ULONG y);
77 ULONG MsgHitTest(ULONG x, ULONG y);
78 ULONG MsgSize(ULONG width, ULONG height, BOOL fMinimize, BOOL fMaximize);
79virtual ULONG MsgActivate(BOOL fActivate, BOOL fMinimized, HWND hwnd);
80 ULONG MsgSetFocus(HWND hwnd);
81 ULONG MsgKillFocus(HWND hwnd);
82 ULONG MsgTimer(ULONG TimerID);
83 ULONG MsgSysTimer(ULONG TimerID);
84 ULONG MsgScroll(ULONG msg, ULONG scrollCode, ULONG scrollPos);
85 ULONG MsgCommand(ULONG cmd, ULONG Id, HWND hwnd);
86 ULONG MsgSysCommand(ULONG win32sc, ULONG x, ULONG y);
87 ULONG MsgChar(ULONG cmd, ULONG repeatcnt, ULONG scancode, ULONG vkey, ULONG keyflags);
88 ULONG MsgKeyUp (ULONG repeatCount, ULONG scancode, ULONG virtualKey);
89 ULONG MsgKeyDown (ULONG repeatCount, ULONG scancode, ULONG virtualKey, BOOL keyWasPressed);
90 ULONG MsgSysKeyUp (ULONG repeatCount, ULONG scancode, ULONG virtualKey);
91 ULONG MsgSysKeyDown (ULONG repeatCount, ULONG scancode, ULONG virtualKey, BOOL keyWasPressed);
92 ULONG MsgButton(ULONG msg, ULONG ncx, ULONG ncy, ULONG clx, ULONG cly);
93 ULONG MsgMouseMove(ULONG keystate, ULONG x, ULONG y);
94 ULONG MsgPaint(ULONG tmp1, BOOL select = TRUE);
95 ULONG MsgEraseBackGround(HDC hdc);
96 ULONG MsgSetText(LPSTR lpsz, LONG cch);
97 ULONG MsgGetTextLength();
98 char *MsgGetText();
99 ULONG MsgContextMenu(ULONG x,ULONG y);
100 void MsgInitMenu(HWND hMenu);
101 VOID updateWindowStyle(DWORD oldExStyle,DWORD oldStyle);
102
103virtual LONG SetWindowLongA(int index, ULONG value, BOOL fUnicode = FALSE);
104virtual ULONG GetWindowLongA(int index, BOOL fUnicode = FALSE);
105virtual WORD SetWindowWord(int index, WORD value);
106virtual WORD GetWindowWord(int index);
107
108 DWORD getStyle() { return dwStyle; };
109 void setStyle(DWORD newstyle) { dwStyle = newstyle; };
110 DWORD getExStyle() { return dwExStyle; };
111 void setExStyle(DWORD newexstyle) { dwExStyle = newexstyle; };
112 HWND getWindowHandle() { return Win32Hwnd; };
113 HWND getOS2WindowHandle() { return OS2Hwnd; };
114 HWND getOS2FrameWindowHandle() { return OS2HwndFrame; };
115 Win32WndClass *getWindowClass() { return windowClass; };
116
117 DWORD getWindowContextHelpId() { return contextHelpId; };
118 void setWindowContextHelpId(DWORD id){ contextHelpId = id; };
119
120 BOOL isFrameWindow();
121virtual BOOL isMDIClient();
122virtual BOOL isMDIChild();
123
124 BOOL fHasParentDC() { return fParentDC; };
125
126Win32BaseWindow *getParent();
127 void setParent(Win32BaseWindow *pwindow) { ChildWindow::SetParent((ChildWindow *)pwindow); };
128 WNDPROC getWindowProc() { return win32wndproc; };
129 void setWindowProc(WNDPROC newproc) { win32wndproc = newproc; };
130 DWORD getWindowId() { return windowId; };
131 void setWindowId(DWORD id);
132 ULONG getWindowHeight() { return rectClient.bottom - rectClient.top; };
133 ULONG getWindowWidth() { return rectClient.right - rectClient.left; };
134 BOOL isChild();
135 PRECT getClientRect() { return &rectClient; };
136 void setClientRect(PRECT rect) { rectClient = *rect; };
137 PRECT getWindowRect() { return &rectWindow; };
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 void setWindowRect(LONG left, LONG top, LONG right, LONG bottom)
144 {
145 rectWindow.left = left; rectWindow.top = top;
146 rectWindow.right = right; rectWindow.bottom = bottom;
147 };
148 void setWindowRect(PRECT rect) { rectWindow = *rect; };
149 DWORD getFlags() { return flags; };
150 void setFlags(DWORD newflags) { flags = newflags; };
151
152 HACCEL GetAccelTable() { return (HACCEL) acceltableResource; };
153 BOOL SetAccelTable(ULONG hAccel);
154
155 HMENU GetMenu() { return (HMENU) OS2HwndMenu; };
156 BOOL SetMenu(ULONG hMenu);
157
158 BOOL SetIcon(HICON hIcon);
159 HICON GetIcon() { return (HICON) iconResource; };
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 BOOL GetWindowRect(PRECT pRect);
195 int GetWindowTextLength();
196 int GetWindowTextA(LPSTR lpsz, int cch);
197 int GetWindowTextW(LPWSTR lpsz, int cch);
198 BOOL SetWindowTextA(LPSTR lpsz);
199 BOOL SetWindowTextW(LPWSTR lpsz);
200 BOOL hasWindowName(LPSTR wndname, BOOL fUnicode = 0);
201Win32WndClass *getClass() { return windowClass; };
202 char *getWindowNameA() { return windowNameA; };
203Win32BaseWindow *getOwner() { return owner; };
204
205 SCROLLBAR_INFO *getScrollInfo(int nBar);
206 HWND getVertScrollHandle() { return hwndVertScroll; };
207 VOID setVertScrollHandle(HWND newHandle) { hwndVertScroll = newHandle; }
208 HWND getHorzScrollHandle() { return hwndHorzScroll; };
209 VOID setHorzScrollHandle(HWND newHandle) { hwndHorzScroll = newHandle; }
210 VOID subclassScrollBars(BOOL subHorz,BOOL subVert);
211 BOOL showScrollBars(BOOL changeHorz,BOOL changeVert,BOOL fShow);
212
213 LRESULT SendMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
214 LRESULT SendMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
215 LRESULT SendMessageToProcess(UINT msg, WPARAM wParam, LPARAM lParam, BOOL fUnicode);
216 BOOL PostMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
217 BOOL PostMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
218 void PostMessage(POSTMSG_PACKET *packet);
219static BOOL PostThreadMessageA(ULONG threadid, UINT msg, WPARAM wParam, LPARAM lParam);
220static BOOL PostThreadMessageW(ULONG threadid, UINT msg, WPARAM wParam, LPARAM lParam);
221static LRESULT BroadcastMessageA(int type, UINT msg, WPARAM wParam, LPARAM lParam);
222static LRESULT BroadcastMessageW(int type, UINT msg, WPARAM wParam, LPARAM lParam);
223
224 LRESULT DefWindowProcA(UINT Msg, WPARAM wParam, LPARAM lParam);
225 LRESULT DefWindowProcW(UINT msg, WPARAM wParam, LPARAM lParam);
226
227 LRESULT DefWndControlColor(UINT ctlType, HDC hdc);
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 ULONG getBorderWidth() { return borderWidth; };
256 ULONG getBorderHeight() { return borderHeight; };
257
258static void NC_AdjustRectInner(LPRECT rect, DWORD style, DWORD exStyle);
259static void NC_AdjustRectOuter(LPRECT rect, DWORD style, BOOL menu, DWORD exStyle);
260static BOOL WindowNeedsWMBorder( DWORD style, DWORD exStyle );
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
298 BOOL isIcon;
299 BOOL fFirstShow;
300 BOOL fIsDialog;
301 BOOL fIsModalDialog;
302 BOOL fIsModalDialogOwner;
303 HWND OS2HwndModalDialog;
304 BOOL fInternalMsg; //Used to distinguish between messages
305 //sent by PM and those sent by apps
306 BOOL fNoSizeMsg;
307 BOOL fIsDestroyed;
308 BOOL fCreated;
309 BOOL fTaskList; //should be listed in PM tasklist or not
310 BOOL fParentDC;
311
312 PVOID pOldFrameProc;
313 ULONG borderWidth;
314 ULONG borderHeight;
315
316 PVOID pOldWndProc;
317 BOOL fIsSubclassedOS2Wnd; //subclassed OS/2 window: Netscape plug-in/scrollbar
318
319 Win32BaseWindow *owner;
320
321 Win32Resource *acceltableResource;
322 Win32Resource *iconResource;
323
324 char *windowNameA;
325 WCHAR *windowNameW;
326 ULONG wndNameLength; //including 0 terminator
327
328 ULONG *userWindowLong;
329 ULONG nrUserWindowLong;
330
331 RECT rectWindow;
332 RECT rectClient;
333
334CREATESTRUCTA *tmpcs; //temporary pointer to CREATESTRUCT used in CreateWindowEx
335 ULONG sw; //set in CreateWindowExA, used in MsgCreate method
336
337SCROLLBAR_INFO *vertScrollInfo;
338SCROLLBAR_INFO *horzScrollInfo;
339 HWND hwndHorzScroll; //os/2 handle
340 HWND hwndVertScroll; //os/2 handle
341
342Win32WndClass *windowClass;
343
344static GenericObject *windows;
345
346private:
347#ifndef OS2_INCLUDED
348 void GetMinMaxInfo(POINT *maxSize, POINT *maxPos, POINT *minTrack, POINT *maxTrack );
349 LONG HandleWindowPosChanging(WINDOWPOS *winpos);
350 LONG HandleSysCommand(WPARAM wParam, POINT *pt32);
351
352 LONG SendNCCalcSize(BOOL calcValidRect,
353 RECT *newWindowRect, RECT *oldWindowRect,
354 RECT *oldClientRect, WINDOWPOS *winpos,
355 RECT *newClientRect );
356
357 LONG NCHandleCalcSize(WPARAM wParam, NCCALCSIZE_PARAMS *ncsize);
358
359 LRESULT SendInternalMessage(ULONG msg, WPARAM wParam, LPARAM lParam)
360 {
361 if(isUnicode)
362 return SendInternalMessageW(msg, wParam, lParam);
363 else return SendInternalMessageA(msg, wParam, lParam);
364 }
365#endif
366
367public:
368 void SetFakeOpen32() { WinSetDAXData (OS2Hwnd, &fakeWinBase); }
369 void RemoveFakeOpen32() { WinSetDAXData (OS2Hwnd, NULL); }
370
371 fakeOpen32WinBaseClass fakeWinBase;
372
373 BOOL isOwnDC() { return (windowClass && windowClass->getStyle() & CS_OWNDC_W); }
374 HDC getOwnDC() { return ownDC; }
375 void setOwnDC(HDC hdc) { ownDC = hdc; }
376protected:
377 HDC ownDC;
378
379 ULONG EraseBkgndFlag:1,
380 PSEraseFlag:1,
381 SupressEraseFlag:1,
382 filler:29;
383public:
384 VOID setEraseBkgnd (BOOL erase, BOOL PSErase = FALSE)
385 { EraseBkgndFlag = erase; PSEraseFlag = PSErase; }
386 VOID setSupressErase (BOOL erase = FALSE)
387 { SupressEraseFlag = erase; }
388 BOOL isEraseBkgnd() { return EraseBkgndFlag; }
389 BOOL isPSErase() { return EraseBkgndFlag | PSEraseFlag; }
390 BOOL isSupressErase() { return SupressEraseFlag; }
391};
392
393
394#define BUTTON_LEFTDOWN 0
395#define BUTTON_LEFTUP 1
396#define BUTTON_LEFTDBLCLICK 2
397#define BUTTON_RIGHTUP 3
398#define BUTTON_RIGHTDOWN 4
399#define BUTTON_RIGHTDBLCLICK 5
400#define BUTTON_MIDDLEUP 6
401#define BUTTON_MIDDLEDOWN 7
402#define BUTTON_MIDDLEDBLCLICK 8
403
404#define WMMOVE_LBUTTON 1
405#define WMMOVE_MBUTTON 2
406#define WMMOVE_RBUTTON 4
407#define WMMOVE_CTRL 8
408#define WMMOVE_SHIFT 16
409
410
411#define CMD_MENU 1
412#define CMD_CONTROL 2
413#define CMD_ACCELERATOR 3
414
415#define KEY_ALTDOWN 1
416#define KEY_PREVDOWN 2
417#define KEY_UP 4
418#define KEY_DEADKEY 8
419
420#endif //__cplusplus
421
422#endif //__WIN32WNDBASE_H__
Note: See TracBrowser for help on using the repository browser.