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

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

ShowScrollBar fix

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