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

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

removed CS_SIZEREDRAW

File size: 17.2 KB
Line 
1/* $Id: win32wbase.h,v 1.55 1999-12-19 17:46:26 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
44typedef struct
45{
46 ULONG Msg;
47 ULONG wParam;
48 ULONG lParam;
49 ULONG fUnicode;
50} POSTMSG_PACKET;
51
52#define BROADCAST_SEND 0
53#define BROADCAST_POST 1
54
55class Win32BaseWindow : public GenericObject, public ChildWindow
56{
57public:
58 DWORD magic;
59
60 Win32BaseWindow(DWORD objType);
61 Win32BaseWindow(HWND os2Handle,VOID* win32WndProc);
62 Win32BaseWindow(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode);
63virtual ~Win32BaseWindow();
64
65virtual ULONG MsgCreate(HWND hwndFrame, HWND hwndClient);
66 ULONG MsgQuit();
67 ULONG MsgClose();
68 ULONG MsgDestroy();
69virtual ULONG MsgEnable(BOOL fEnable);
70 ULONG MsgShow(BOOL fShow);
71 ULONG MsgPosChanging(LPARAM lp);
72 ULONG MsgPosChanged(LPARAM lp);
73 ULONG MsgMove(ULONG x, ULONG y);
74 ULONG MsgHitTest(ULONG x, ULONG y);
75 ULONG MsgSize(ULONG width, ULONG height, BOOL fMinimize, BOOL fMaximize);
76virtual ULONG MsgActivate(BOOL fActivate, BOOL fMinimized, HWND hwnd);
77 ULONG MsgSetFocus(HWND hwnd);
78 ULONG MsgKillFocus(HWND hwnd);
79 ULONG MsgTimer(ULONG TimerID);
80 ULONG MsgSysTimer(ULONG TimerID);
81 ULONG MsgScroll(ULONG msg, ULONG scrollCode, ULONG scrollPos);
82 ULONG MsgCommand(ULONG cmd, ULONG Id, HWND hwnd);
83 ULONG MsgSysCommand(ULONG win32sc, ULONG x, ULONG y);
84 ULONG MsgChar(ULONG cmd, ULONG repeatcnt, ULONG scancode, ULONG vkey, ULONG keyflags);
85 ULONG MsgKeyUp (ULONG repeatCount, ULONG scancode, ULONG virtualKey);
86 ULONG MsgKeyDown (ULONG repeatCount, ULONG scancode, ULONG virtualKey, BOOL keyWasPressed);
87 ULONG MsgSysKeyUp (ULONG repeatCount, ULONG scancode, ULONG virtualKey);
88 ULONG MsgSysKeyDown (ULONG repeatCount, ULONG scancode, ULONG virtualKey, BOOL keyWasPressed);
89 ULONG MsgButton(ULONG msg, ULONG ncx, ULONG ncy, ULONG clx, ULONG cly);
90 ULONG MsgMouseMove(ULONG keystate, ULONG x, ULONG y);
91 ULONG MsgPaint(ULONG tmp1, BOOL select = TRUE);
92 ULONG MsgEraseBackGround(HDC hdc);
93 ULONG MsgSetText(LPSTR lpsz, LONG cch);
94 ULONG MsgGetTextLength();
95 char *MsgGetText();
96 ULONG MsgContextMenu(ULONG x,ULONG y);
97 void MsgInitMenu(HWND hMenu);
98 VOID updateWindowStyle(DWORD oldExStyle,DWORD oldStyle);
99
100virtual LONG SetWindowLongA(int index, ULONG value, BOOL fUnicode = FALSE);
101virtual ULONG GetWindowLongA(int index, BOOL fUnicode = FALSE);
102virtual WORD SetWindowWord(int index, WORD value);
103virtual WORD GetWindowWord(int index);
104
105 DWORD getStyle() { return dwStyle; };
106 void setStyle(DWORD newstyle) { dwStyle = newstyle; };
107 DWORD getExStyle() { return dwExStyle; };
108 void setExStyle(DWORD newexstyle) { dwExStyle = newexstyle; };
109 HWND getWindowHandle() { return Win32Hwnd; };
110 HWND getOS2WindowHandle() { return OS2Hwnd; };
111 HWND getOS2FrameWindowHandle() { return OS2HwndFrame; };
112 Win32WndClass *getWindowClass() { return windowClass; };
113
114 DWORD getWindowContextHelpId() { return contextHelpId; };
115 void setWindowContextHelpId(DWORD id){ contextHelpId = id; };
116
117 BOOL isFrameWindow();
118virtual BOOL isMDIClient();
119virtual BOOL isMDIChild();
120
121 BOOL fHasParentDC() { return fParentDC; };
122
123Win32BaseWindow *getParent();
124 void setParent(Win32BaseWindow *pwindow) { ChildWindow::SetParent((ChildWindow *)pwindow); };
125 WNDPROC getWindowProc() { return win32wndproc; };
126 void setWindowProc(WNDPROC newproc) { win32wndproc = newproc; };
127 DWORD getWindowId() { return windowId; };
128 void setWindowId(DWORD id);
129 ULONG getWindowHeight() { return rectClient.bottom - rectClient.top; };
130 ULONG getWindowWidth() { return rectClient.right - rectClient.left; };
131 BOOL isChild();
132 PRECT getClientRect() { return &rectClient; };
133 void setClientRect(PRECT rect) { rectClient = *rect; };
134 PRECT getWindowRect() { return &rectWindow; };
135 void setClientRect(LONG left, LONG top, LONG right, LONG bottom)
136 {
137 rectClient.left = left; rectClient.top = top;
138 rectClient.right = right; rectClient.bottom = bottom;
139 };
140 void setWindowRect(LONG left, LONG top, LONG right, LONG bottom)
141 {
142 rectWindow.left = left; rectWindow.top = top;
143 rectWindow.right = right; rectWindow.bottom = bottom;
144 };
145 void setWindowRect(PRECT rect) { rectWindow = *rect; };
146 DWORD getFlags() { return flags; };
147 void setFlags(DWORD newflags) { flags = newflags; };
148
149 HACCEL GetAccelTable() { return (HACCEL) acceltableResource; };
150 BOOL SetAccelTable(ULONG hAccel);
151
152 HMENU GetMenu() { return (HMENU) OS2HwndMenu; };
153 BOOL SetMenu(ULONG hMenu);
154
155 BOOL SetIcon(HICON hIcon);
156 HICON GetIcon() { return (HICON) iconResource; };
157
158 BOOL ShowWindow(ULONG nCmdShow);
159 BOOL SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags);
160 BOOL SetWindowPlacement(WINDOWPLACEMENT *winpos);
161 BOOL DestroyWindow();
162 HWND SetActiveWindow();
163 HWND GetParent();
164 HWND SetParent(HWND hwndNewParent);
165 BOOL IsChild(HWND hwndParent);
166 HWND GetTopWindow();
167Win32BaseWindow *GetTopParent();
168 BOOL UpdateWindow();
169 BOOL IsIconic();
170 HWND GetWindow(UINT uCmd);
171 virtual BOOL EnableWindow(BOOL fEnable);
172 BOOL CloseWindow();
173 static HWND GetActiveWindow();
174 //Window handle has already been verified, so just return true
175 BOOL IsWindow() { return TRUE; };
176 BOOL IsDialog() { return fIsDialog; };
177 BOOL IsModalDialog() { return fIsModalDialog; };
178 BOOL IsModalDialogOwner() { return fIsModalDialogOwner; };
179 VOID setModalDialogOwner(BOOL fMDO) { fIsModalDialogOwner = fMDO; };
180 VOID setOS2HwndModalDialog(HWND aHwnd) { OS2HwndModalDialog = aHwnd; };
181 HWND getOS2HwndModalDialog() { return OS2HwndModalDialog; };
182 BOOL CanReceiveSizeMsgs() { return !fNoSizeMsg; };
183 BOOL InMovingChildren() { return fMovingChildren; };
184 VOID setMovingChildren(BOOL fMC) { fMovingChildren = fMC; };
185 BOOL IsWindowDestroyed() { return fIsDestroyed; };
186 BOOL IsWindowEnabled();
187 BOOL IsWindowVisible();
188 //Created with CreateWindowExA or ExW
189// BOOL IsUnicode() { return isUnicode; };
190 //Window procedure type
191 BOOL IsWindowUnicode();
192
193 BOOL GetWindowRect(PRECT pRect);
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);
200Win32WndClass *getClass() { return windowClass; };
201 char *getWindowNameA() { return windowNameA; };
202Win32BaseWindow *getOwner() { return owner; };
203
204 SCROLLBAR_INFO *getScrollInfo(int nBar);
205 HWND getVertScrollHandle() { return hwndVertScroll; };
206 VOID setVertScrollHandle(HWND newHandle) { hwndVertScroll = newHandle; }
207 HWND getHorzScrollHandle() { return hwndHorzScroll; };
208 VOID setHorzScrollHandle(HWND newHandle) { hwndHorzScroll = newHandle; }
209 VOID subclassScrollBars(BOOL subHorz,BOOL subVert);
210 BOOL showScrollBars(BOOL changeHorz,BOOL changeVert,BOOL fShow);
211
212 LRESULT SendMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
213 LRESULT SendMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
214 BOOL PostMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
215 BOOL PostMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
216 ULONG PostMessage(POSTMSG_PACKET *packet);
217static BOOL PostThreadMessageA(ULONG threadid, UINT msg, WPARAM wParam, LPARAM lParam);
218static BOOL PostThreadMessageW(ULONG threadid, UINT 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
228 void NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam);
229
230Win32BaseWindow *FindWindowById(int id);
231
232 static HWND FindWindowEx(HWND hwndParent, HWND hwndChildAfter, LPSTR lpszClass, LPSTR lpszWindow,
233 BOOL fUnicode = 0);
234
235 BOOL EnumChildWindows(WNDENUMPROC lpfn, LPARAM lParam);
236 BOOL EnumThreadWindows(DWORD dwThreadId, WNDENUMPROC lpfn, LPARAM lParam);
237 BOOL EnumWindows(WNDENUMPROC lpfn, LPARAM lParam);
238
239 HWND getNextDlgTabItem(HWND hwndCtrl, BOOL fPrevious);
240 HWND getNextDlgGroupItem(HWND hwndCtrl, BOOL fPrevious);
241
242 static HWND Win32ToOS2Handle(HWND hwnd);
243 static HWND Win32ToOS2FrameHandle(HWND hwnd);
244 static HWND OS2ToWin32Handle(HWND hwnd);
245
246static Win32BaseWindow *GetWindowFromHandle(HWND hwnd);
247static Win32BaseWindow *GetWindowFromOS2Handle(HWND hwnd);
248static Win32BaseWindow *GetWindowFromOS2FrameHandle(HWND hwnd);
249
250 static void DestroyAll();
251
252 PVOID getOldFrameProc() { return pOldFrameProc; };
253 VOID setOldFrameProc(PVOID aOldFrameProc) { pOldFrameProc = aOldFrameProc; };
254 ULONG getBorderWidth() { return borderWidth; };
255 ULONG getBorderHeight() { return borderHeight; };
256
257static void NC_AdjustRectInner(LPRECT rect, DWORD style, DWORD exStyle);
258static void NC_AdjustRectOuter(LPRECT rect, DWORD style, BOOL menu, DWORD exStyle);
259static BOOL WindowNeedsWMBorder( DWORD style, DWORD exStyle );
260
261 PVOID getOldWndProc() { return pOldWndProc; }
262 VOID setOldWndProc(PVOID aOldWndProc) { pOldWndProc = aOldWndProc; }
263 BOOL isSubclassedOS2Wnd() { return fIsSubclassedOS2Wnd; };
264
265protected:
266#ifndef OS2_INCLUDED
267 BOOL CreateWindowExA(CREATESTRUCTA *lpCreateStruct, ATOM classAtom);
268#endif
269 LRESULT SendInternalMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
270 LRESULT SendInternalMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
271 void Init();
272 void setExtendedKey(ULONG virtualkey, ULONG *lParam);
273
274 HWND OS2Hwnd;
275 HWND OS2HwndFrame;
276 HWND OS2HwndMenu;
277 HWND Win32Hwnd;
278 BOOL isUnicode;
279
280 int posx, posy, width, height;
281
282 // values normally contained in the standard window words
283 ULONG dwExStyle; //GWL_EXSTYLE
284 ULONG dwStyle; //GWL_STYLE
285 WNDPROC win32wndproc; //GWL_WNDPROC
286 ULONG hInstance; //GWL_HINSTANCE
287//Moved in ChildWindow class
288///// Win32BaseWindow *parent; //GWL_HWNDPARENT
289 ULONG windowId; //GWL_ID
290 ULONG userData; //GWL_USERDATA
291
292 HWND hwndLinkAfter;
293 DWORD flags;
294 DWORD contextHelpId;
295 LONG lastHitTestVal; //Last value returned by WM_NCHITTEST handler
296
297 BOOL isIcon;
298 BOOL fFirstShow;
299 BOOL fIsDialog;
300 BOOL fIsModalDialog;
301 BOOL fIsModalDialogOwner;
302 HWND OS2HwndModalDialog;
303 BOOL fInternalMsg; //Used to distinguish between messages
304 //sent by PM and those sent by apps
305 BOOL fNoSizeMsg;
306 BOOL fMovingChildren;
307 BOOL fIsDestroyed;
308 BOOL fDestroyWindowCalled; //DestroyWindow was called for this window
309 BOOL fCreated;
310 BOOL fTaskList; //should be listed in PM tasklist or not
311 BOOL fParentDC;
312
313 DWORD dwThreadId; //id of thread that created this window
314 DWORD dwProcessId; //id of process that created this window
315 PVOID pOldFrameProc;
316 ULONG borderWidth;
317 ULONG borderHeight;
318
319 PVOID pOldWndProc;
320 BOOL fIsSubclassedOS2Wnd; //subclassed OS/2 window: Netscape plug-in/scrollbar
321
322 Win32BaseWindow *owner;
323
324 Win32Resource *acceltableResource;
325 Win32Resource *iconResource;
326
327 char *windowNameA;
328 WCHAR *windowNameW;
329 ULONG wndNameLength; //including 0 terminator
330
331 ULONG *userWindowLong;
332 ULONG nrUserWindowLong;
333
334 RECT rectWindow;
335 RECT rectClient;
336
337CREATESTRUCTA *tmpcs; //temporary pointer to CREATESTRUCT used in CreateWindowEx
338 ULONG sw; //set in CreateWindowExA, used in MsgCreate method
339
340SCROLLBAR_INFO *vertScrollInfo;
341SCROLLBAR_INFO *horzScrollInfo;
342 HWND hwndHorzScroll; //os/2 handle
343 HWND hwndVertScroll; //os/2 handle
344
345Win32WndClass *windowClass;
346
347static GenericObject *windows;
348
349private:
350#ifndef OS2_INCLUDED
351 void GetMinMaxInfo(POINT *maxSize, POINT *maxPos, POINT *minTrack, POINT *maxTrack );
352 LONG HandleWindowPosChanging(WINDOWPOS *winpos);
353 LONG HandleSysCommand(WPARAM wParam, POINT *pt32);
354
355 LONG SendNCCalcSize(BOOL calcValidRect,
356 RECT *newWindowRect, RECT *oldWindowRect,
357 RECT *oldClientRect, WINDOWPOS *winpos,
358 RECT *newClientRect );
359
360 LONG NCHandleCalcSize(WPARAM wParam, NCCALCSIZE_PARAMS *ncsize);
361
362 LRESULT SendInternalMessage(ULONG msg, WPARAM wParam, LPARAM lParam)
363 {
364 if(isUnicode)
365 return SendInternalMessageW(msg, wParam, lParam);
366 else return SendInternalMessageA(msg, wParam, lParam);
367 }
368#endif
369
370public:
371 void SetFakeOpen32() { WinSetDAXData (OS2Hwnd, &fakeWinBase); }
372 void RemoveFakeOpen32() { WinSetDAXData (OS2Hwnd, NULL); }
373
374 fakeOpen32WinBaseClass fakeWinBase;
375
376 BOOL isOwnDC() { return (windowClass && windowClass->getStyle() & CS_OWNDC_W); }
377 HDC getOwnDC() { return ownDC; }
378 void setOwnDC(HDC hdc) { ownDC = hdc; }
379protected:
380 HDC ownDC;
381
382 ULONG EraseBkgndFlag:1,
383 PSEraseFlag:1,
384 SupressEraseFlag:1,
385 filler:29;
386public:
387 VOID setEraseBkgnd (BOOL erase, BOOL PSErase = FALSE)
388 { EraseBkgndFlag = erase; PSEraseFlag = PSErase; }
389 VOID setSupressErase (BOOL erase = FALSE)
390 { SupressEraseFlag = erase; }
391 BOOL isEraseBkgnd() { return EraseBkgndFlag; }
392 BOOL isPSErase() { return EraseBkgndFlag | PSEraseFlag; }
393 BOOL isSupressErase() { return SupressEraseFlag; }
394};
395
396
397#define BUTTON_LEFTDOWN 0
398#define BUTTON_LEFTUP 1
399#define BUTTON_LEFTDBLCLICK 2
400#define BUTTON_RIGHTUP 3
401#define BUTTON_RIGHTDOWN 4
402#define BUTTON_RIGHTDBLCLICK 5
403#define BUTTON_MIDDLEUP 6
404#define BUTTON_MIDDLEDOWN 7
405#define BUTTON_MIDDLEDBLCLICK 8
406
407#define WMMOVE_LBUTTON 1
408#define WMMOVE_MBUTTON 2
409#define WMMOVE_RBUTTON 4
410#define WMMOVE_CTRL 8
411#define WMMOVE_SHIFT 16
412
413
414#define CMD_MENU 1
415#define CMD_CONTROL 2
416#define CMD_ACCELERATOR 3
417
418#define KEY_ALTDOWN 1
419#define KEY_PREVDOWN 2
420#define KEY_UP 4
421#define KEY_DEADKEY 8
422
423#endif //__cplusplus
424
425#endif //__WIN32WNDBASE_H__
Note: See TracBrowser for help on using the repository browser.