source: trunk/src/user32/new/win32wbase.h@ 2384

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

scrollbar support and many other things

File size: 17.3 KB
Line 
1/* $Id: win32wbase.h,v 1.20 2000-01-09 14:14:25 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//PostThreadMessage is done through Open32; which means the message id will be translated
42//(0xc00 added)
43#define OPEN32_MSGDIFF 0xC00
44#define WIN32APP_POSTMSG (0x1000+OPEN32_MSGDIFF)
45
46#define WIN32MSG_MAGICA 0x12345678
47#define WIN32MSG_MAGICW 0x12345679
48
49typedef struct
50{
51 ULONG Msg;
52 ULONG wParam;
53 ULONG lParam;
54} POSTMSG_PACKET;
55
56#define BROADCAST_SEND 0
57#define BROADCAST_POST 1
58
59class Win32BaseWindow : public GenericObject, public ChildWindow
60{
61public:
62 DWORD magic;
63
64 Win32BaseWindow(DWORD objType);
65 Win32BaseWindow(HWND os2Handle,VOID* win32WndProc);
66 Win32BaseWindow(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode);
67virtual ~Win32BaseWindow();
68
69virtual ULONG MsgCreate(HWND hwndFrame, HWND hwndClient);
70 ULONG MsgQuit();
71 ULONG MsgClose();
72 ULONG MsgDestroy();
73virtual ULONG MsgEnable(BOOL fEnable);
74 ULONG MsgShow(BOOL fShow);
75 ULONG MsgPosChanging(LPARAM lp);
76 ULONG MsgPosChanged(LPARAM lp);
77virtual ULONG MsgActivate(BOOL fActivate, BOOL fMinimized, HWND hwnd);
78 ULONG MsgSetFocus(HWND hwnd);
79 ULONG MsgKillFocus(HWND hwnd);
80 ULONG MsgScroll(ULONG msg, ULONG scrollCode, ULONG scrollPos);
81 ULONG MsgButton(MSG *msg);
82 ULONG MsgMouseMove(MSG *msg);
83 ULONG MsgPaint(ULONG tmp1, BOOL select = TRUE);
84 ULONG MsgEraseBackGround(HDC hdc);
85 ULONG MsgInitMenu(MSG *msg);
86 ULONG MsgHitTest(MSG *msg);
87 ULONG MsgNCPaint();
88 ULONG MsgFormatFrame();
89 ULONG DispatchMsgA(MSG *msg);
90 ULONG DispatchMsgW(MSG *msg);
91
92 ULONG MsgSetText(LPSTR lpsz, LONG cch);
93 ULONG MsgGetTextLength();
94 char *MsgGetText();
95 ULONG MsgContextMenu(ULONG x,ULONG y);
96 VOID updateWindowStyle(DWORD oldExStyle,DWORD oldStyle);
97
98virtual LONG SetWindowLongA(int index, ULONG value, BOOL fUnicode = FALSE);
99virtual ULONG GetWindowLongA(int index, BOOL fUnicode = FALSE);
100virtual WORD SetWindowWord(int index, WORD value);
101virtual WORD GetWindowWord(int index);
102
103 DWORD getStyle() { return dwStyle; };
104 void setStyle(DWORD newstyle) { dwStyle = newstyle; };
105 DWORD getExStyle() { return dwExStyle; };
106 void setExStyle(DWORD newexstyle) { dwExStyle = newexstyle; };
107 ULONG getInstance() { return hInstance; };
108 void setInstance(ULONG newinstance) { hInstance = newinstance; };
109 HWND getWindowHandle() { return Win32Hwnd; };
110 HWND getOS2WindowHandle() { return OS2Hwnd; };
111 HWND getOS2FrameWindowHandle() { return OS2HwndFrame; };
112 Win32WndClass *getWindowClass() { return windowClass; };
113
114 LONG getLastHitTestVal() { return lastHitTestVal; }
115 BOOL getIgnoreHitTest() { return fIgnoreHitTest; }
116 VOID setIgnoreHitTest(BOOL ignore) { fIgnoreHitTest = ignore; }
117
118 DWORD getWindowContextHelpId() { return contextHelpId; };
119 void setWindowContextHelpId(DWORD id){ contextHelpId = id; };
120
121 BOOL isFrameWindow();
122virtual BOOL isMDIClient();
123virtual BOOL isMDIChild();
124
125 BOOL fHasParentDC() { return fParentDC; };
126
127Win32BaseWindow *getParent();
128 void setParent(Win32BaseWindow *pwindow) { ChildWindow::SetParent((ChildWindow *)pwindow); };
129 WNDPROC getWindowProc() { return win32wndproc; };
130 void setWindowProc(WNDPROC newproc) { win32wndproc = newproc; };
131 DWORD getWindowId() { return windowId; };
132 void setWindowId(DWORD id);
133 ULONG getWindowHeight() { return rectWindow.bottom - rectWindow.top; };
134 ULONG getWindowWidth() { return rectWindow.right - rectWindow.left; };
135 ULONG getClientHeight() { return rectClient.bottom - rectClient.top; };
136 ULONG getClientWidth() { return rectClient.right - rectClient.left; };
137 BOOL isChild();
138 PRECT getClientRectPtr() { return &rectClient; };
139 void getClientRect(PRECT rect)
140 {
141 *rect = rectClient;
142 rect->right -= rect->left;
143 rect->bottom -= rect->top;
144 rect->left = rect->top = 0;
145 }
146 void setClientRect(PRECT rect) { rectClient = *rect; };
147 PRECT getWindowRect() { return &rectWindow; };
148 void setClientRect(LONG left, LONG top, LONG right, LONG bottom)
149 {
150 rectClient.left = left; rectClient.top = top;
151 rectClient.right = right; rectClient.bottom = bottom;
152 };
153 void setWindowRect(LONG left, LONG top, LONG right, LONG bottom)
154 {
155 rectWindow.left = left; rectWindow.top = top;
156 rectWindow.right = right; rectWindow.bottom = bottom;
157 };
158 void setWindowRect(PRECT rect) { rectWindow = *rect; };
159 DWORD getFlags() { return flags; };
160 void setFlags(DWORD newflags) { flags = newflags; };
161
162 HMENU GetMenu() { return hMenu; };
163 VOID SetMenu(HMENU newMenu) { hMenu = newMenu; };
164 HMENU GetSysMenu() { return hSysMenu; };
165 VOID SetSysMenu(HMENU newSysMenu) { hSysMenu = newSysMenu; };
166
167 BOOL SetIcon(HICON hIcon);
168 HICON GetIcon() { return (HICON) iconResource; };
169
170 void SetWindowRegion(HRGN hRegion) { hWindowRegion = hRegion; };
171 HRGN GetWindowRegion() { return hWindowRegion; };
172
173 BOOL ShowWindow(ULONG nCmdShow);
174 BOOL SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags);
175 BOOL SetWindowPlacement(WINDOWPLACEMENT *winpos);
176 BOOL DestroyWindow();
177 HWND SetActiveWindow();
178 HWND GetParent();
179 HWND SetParent(HWND hwndNewParent);
180 BOOL IsChild(HWND hwndParent);
181 HWND GetTopWindow();
182Win32BaseWindow *GetTopParent();
183 BOOL UpdateWindow();
184 BOOL IsIconic();
185 HWND GetWindow(UINT uCmd);
186 virtual BOOL EnableWindow(BOOL fEnable);
187 BOOL CloseWindow();
188 static HWND GetActiveWindow();
189 //Window handle has already been verified, so just return true
190 BOOL IsWindow() { return TRUE; };
191 BOOL IsDialog() { return fIsDialog; };
192 BOOL IsModalDialog() { return fIsModalDialog; };
193 BOOL IsModalDialogOwner() { return fIsModalDialogOwner; };
194 VOID setModalDialogOwner(BOOL fMDO) { fIsModalDialogOwner = fMDO; };
195 VOID setOS2HwndModalDialog(HWND aHwnd) { OS2HwndModalDialog = aHwnd; };
196 HWND getOS2HwndModalDialog() { return OS2HwndModalDialog; };
197 BOOL CanReceiveSizeMsgs() { return !fNoSizeMsg; };
198 BOOL IsWindowCreated() { return fCreated; }
199 BOOL IsWindowDestroyed() { return fIsDestroyed; };
200 BOOL IsWindowEnabled();
201 BOOL IsWindowVisible();
202 //Created with CreateWindowExA or ExW
203// BOOL IsUnicode() { return isUnicode; };
204 //Window procedure type
205 BOOL IsWindowUnicode();
206
207 BOOL GetWindowRect(PRECT pRect);
208 int GetWindowTextLength();
209 int GetWindowTextA(LPSTR lpsz, int cch);
210 int GetWindowTextW(LPWSTR lpsz, int cch);
211 BOOL SetWindowTextA(LPSTR lpsz);
212 BOOL SetWindowTextW(LPWSTR lpsz);
213 BOOL hasWindowName(LPSTR wndname, BOOL fUnicode = 0);
214 CHAR *getWindowNamePtrA();
215 WCHAR *getWindowNamePtrW();
216 VOID freeWindowNamePtr(PVOID namePtr);
217 CHAR *getWindowNameA() { return windowNameA; }; //only for MDI windows!
218 WCHAR *getWindowNameW() { return windowNameW; }; //only for MDI windows!
219Win32WndClass *getClass() { return windowClass; };
220Win32BaseWindow *getOwner() { return owner; };
221 void setOwner(Win32BaseWindow *newOwner) { owner = newOwner; };
222
223 SCROLLBAR_INFO *getScrollInfo(int nBar);
224
225 LRESULT SendMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
226 LRESULT SendMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
227static LRESULT BroadcastMessageA(int type, UINT msg, WPARAM wParam, LPARAM lParam);
228static LRESULT BroadcastMessageW(int type, UINT msg, WPARAM wParam, LPARAM lParam);
229 void CallWindowHookProc(ULONG hooktype, ULONG Msg, WPARAM wParam, LPARAM lParam, BOOL fUnicode = FALSE);
230
231 LRESULT DefWindowProcA(UINT Msg, WPARAM wParam, LPARAM lParam);
232 LRESULT DefWindowProcW(UINT msg, WPARAM wParam, LPARAM lParam);
233
234 LRESULT DefWndControlColor(UINT ctlType, HDC hdc);
235 LRESULT DefWndPrint(HDC hdc,ULONG uFlags);
236
237 void NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam);
238
239Win32BaseWindow *FindWindowById(int id);
240
241 static HWND FindWindowEx(HWND hwndParent, HWND hwndChildAfter, LPSTR lpszClass, LPSTR lpszWindow,
242 BOOL fUnicode = 0);
243
244 BOOL EnumChildWindows(WNDENUMPROC lpfn, LPARAM lParam);
245 BOOL EnumThreadWindows(DWORD dwThreadId, WNDENUMPROC lpfn, LPARAM lParam);
246 BOOL EnumWindows(WNDENUMPROC lpfn, LPARAM lParam);
247
248 HWND getNextDlgTabItem(HWND hwndCtrl, BOOL fPrevious);
249 HWND getNextDlgGroupItem(HWND hwndCtrl, BOOL fPrevious);
250
251 static HWND Win32ToOS2Handle(HWND hwnd);
252 static HWND Win32ToOS2FrameHandle(HWND hwnd);
253 static HWND OS2ToWin32Handle(HWND hwnd);
254
255static Win32BaseWindow *GetWindowFromHandle(HWND hwnd);
256static Win32BaseWindow *GetWindowFromOS2Handle(HWND hwnd);
257static Win32BaseWindow *GetWindowFromOS2FrameHandle(HWND hwnd);
258
259 static void DestroyAll();
260
261 PVOID getOldFrameProc() { return pOldFrameProc; };
262 VOID setOldFrameProc(PVOID aOldFrameProc) { pOldFrameProc = aOldFrameProc; };
263 ULONG getBorderWidth() { return borderWidth; };
264 ULONG getBorderHeight() { return borderHeight; };
265
266 PVOID getOldWndProc() { return pOldWndProc; }
267 VOID setOldWndProc(PVOID aOldWndProc) { pOldWndProc = aOldWndProc; }
268 BOOL isSubclassedOS2Wnd() { return fIsSubclassedOS2Wnd; };
269
270protected:
271#ifndef OS2_INCLUDED
272 BOOL CreateWindowExA(CREATESTRUCTA *lpCreateStruct, ATOM classAtom);
273#endif
274 LRESULT SendInternalMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
275 LRESULT SendInternalMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
276 void Init();
277 void setExtendedKey(ULONG virtualkey, ULONG *lParam);
278
279 HWND OS2Hwnd;
280 HWND OS2HwndFrame;
281 HMENU hMenu;
282 HMENU hSysMenu;
283 HWND Win32Hwnd;
284 BOOL isUnicode;
285
286 int posx, posy, width, height;
287
288 // values normally contained in the standard window words
289 ULONG dwExStyle; //GWL_EXSTYLE
290 ULONG dwStyle; //GWL_STYLE
291 WNDPROC win32wndproc; //GWL_WNDPROC
292 ULONG hInstance; //GWL_HINSTANCE
293//Moved in ChildWindow class
294///// Win32BaseWindow *parent; //GWL_HWNDPARENT
295 ULONG windowId; //GWL_ID
296 ULONG userData; //GWL_USERDATA
297
298 HWND hwndLinkAfter;
299 DWORD flags;
300 DWORD contextHelpId;
301 LONG lastHitTestVal; //Last value returned by WM_NCHITTEST handler
302 BOOL fIgnoreHitTest; //Use WinWindowFromPoint during WM_HITTEST
303
304 BOOL isIcon;
305 BOOL fFirstShow;
306 BOOL fIsDialog;
307 BOOL fIsModalDialog;
308 BOOL fIsModalDialogOwner;
309 HWND OS2HwndModalDialog;
310 BOOL fInternalMsg; //Used to distinguish between messages
311 //sent by PM and those sent by apps
312 BOOL fNoSizeMsg;
313 BOOL fIsDestroyed;
314 BOOL fDestroyWindowCalled; //DestroyWindow was called for this window
315 BOOL fCreated;
316 BOOL fTaskList; //should be listed in PM tasklist or not
317 BOOL fParentDC;
318
319 HRGN hWindowRegion;
320
321 DWORD dwThreadId; //id of thread that created this window
322 DWORD dwProcessId; //id of process that created this window
323 PVOID pOldFrameProc;
324 ULONG borderWidth;
325 ULONG borderHeight;
326
327 PVOID pOldWndProc;
328 BOOL fIsSubclassedOS2Wnd; //subclassed OS/2 window: Netscape plug-in/scrollbar
329
330 Win32BaseWindow *owner;
331 Win32Resource *iconResource;
332
333 char *windowNameA;
334 WCHAR *windowNameW;
335 ULONG wndNameLength; //including 0 terminator
336
337 ULONG *userWindowLong;
338 ULONG nrUserWindowLong;
339
340 RECT rectWindow; //relative to screen
341 RECT rectClient; //relative to parent
342
343CREATESTRUCTA *tmpcs; //temporary pointer to CREATESTRUCT used in CreateWindowEx
344 ULONG sw; //set in CreateWindowExA, used in MsgCreate method
345
346SCROLLBAR_INFO *vertScrollInfo;
347SCROLLBAR_INFO *horzScrollInfo;
348
349Win32WndClass *windowClass;
350
351static GenericObject *windows;
352
353private:
354#ifndef OS2_INCLUDED
355 void GetMinMaxInfo(POINT *maxSize, POINT *maxPos, POINT *minTrack, POINT *maxTrack );
356 LONG HandleWindowPosChanging(WINDOWPOS *winpos);
357 LONG HandleNCActivate(WPARAM wParam);
358 VOID TrackMinMaxBox(WORD wParam);
359 VOID TrackCloseButton(WORD wParam);
360 VOID TrackScrollBar(WPARAM wParam,POINT pt);
361 LONG HandleNCLButtonDown(WPARAM wParam,LPARAM lParam);
362 LONG HandleNCLButtonDblClk(WPARAM wParam,LPARAM lParam);
363 BOOL WindowNeedsWMBorder();
364 VOID AdjustRectOuter(LPRECT rect,BOOL menu);
365 VOID AdjustRectInner(LPRECT rect);
366 LONG HandleNCCalcSize(BOOL calcValidRects,RECT *winRect);
367 LONG HandleNCHitTest(POINT pt);
368 VOID GetInsideRect(RECT *rect);
369 VOID DrawFrame(HDC hdc,RECT *rect,BOOL dlgFrame,BOOL active);
370 BOOL DrawSysButton(HDC hdc,BOOL down);
371 BOOL DrawGrayButton(HDC hdc,int x,int y);
372 VOID DrawCloseButton(HDC hdc,BOOL down,BOOL bGrayed);
373 VOID DrawMaxButton(HDC hdc,BOOL down,BOOL bGrayed);
374 VOID DrawMinButton(HDC hdc,BOOL down,BOOL bGrayed);
375 VOID DrawCaption(HDC hdc,RECT *rect,BOOL active);
376 VOID DoNCPaint(HRGN clip,BOOL suppress_menupaint);
377 LONG HandleNCPaint(HRGN clip);
378 LONG HandleSysCommand(WPARAM wParam, POINT *pt32);
379
380 LONG SendNCCalcSize(BOOL calcValidRect,
381 RECT *newWindowRect, RECT *oldWindowRect,
382 RECT *oldClientRect, WINDOWPOS *winpos,
383 RECT *newClientRect );
384
385 LRESULT SendInternalMessage(ULONG msg, WPARAM wParam, LPARAM lParam)
386 {
387 if(isUnicode)
388 return SendInternalMessageW(msg, wParam, lParam);
389 else return SendInternalMessageA(msg, wParam, lParam);
390 }
391#else
392friend BOOL OS2ToWinMsgTranslate(void *pThdb, QMSG *os2Msg, MSG *winMsg, BOOL isUnicode, BOOL fTranslateExtraMsgs);
393#endif
394
395public:
396 void SetFakeOpen32() { WinSetDAXData (OS2Hwnd, &fakeWinBase); }
397 void RemoveFakeOpen32() { WinSetDAXData (OS2Hwnd, NULL); }
398
399 fakeOpen32WinBaseClass fakeWinBase;
400
401 BOOL isOwnDC() { return (windowClass && windowClass->getStyle() & CS_OWNDC_W); }
402 HDC getOwnDC() { return ownDC; }
403 void setOwnDC(HDC hdc) { ownDC = hdc; }
404protected:
405 HDC ownDC;
406
407 ULONG EraseBkgndFlag:1,
408 PSEraseFlag:1,
409 SuppressEraseFlag:1,
410 filler:29;
411public:
412 VOID setEraseBkgnd (BOOL erase, BOOL PSErase = FALSE)
413 { EraseBkgndFlag = erase; PSEraseFlag = PSErase; }
414 VOID setSuppressErase (BOOL erase = FALSE)
415 { SuppressEraseFlag = erase; }
416 BOOL isEraseBkgnd() { return EraseBkgndFlag; }
417 BOOL isPSErase() { return EraseBkgndFlag | PSEraseFlag; }
418 BOOL isSuppressErase() { return SuppressEraseFlag; }
419};
420
421#endif //__cplusplus
422
423#endif //__WIN32WNDBASE_H__
Note: See TracBrowser for help on using the repository browser.