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

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

some fixes

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