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

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

new mapping functions, fixed 1 pixel and window handle bugs

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