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

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

GetSystemMetrics, timer and scrollbar fixes

File size: 14.6 KB
Line 
1/* $Id: win32wbase.h,v 1.33 1999-10-23 16:45:24 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 OFFSET_WIN32PM_SHAREDMEM 8
31#define NROF_WIN32WNDBYTES 12
32
33#define WIN32PM_MAGIC 0x12345678
34#define CheckMagicDword(a) (a==WIN32PM_MAGIC)
35
36#define WIN32APP_USERMSGBASE 0x1000
37
38typedef struct {
39 USHORT cb;
40 Win32BaseWindow *win32wnd;
41 ULONG win32CreateStruct; //or dialog create dword
42} CUSTOMWNDDATA;
43
44typedef struct
45{
46 ULONG Msg;
47 ULONG wParam;
48 ULONG lParam;
49} POSTMSG_PACKET;
50
51#define WM_WIN32_POSTMESSAGEA 0x4000
52#define WM_WIN32_POSTMESSAGEW 0x4001
53
54class Win32BaseWindow : public GenericObject, public ChildWindow
55{
56public:
57 DWORD magic;
58
59 Win32BaseWindow(DWORD objType);
60 Win32BaseWindow(HWND os2Handle,VOID* win32WndProc);
61 Win32BaseWindow(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode);
62virtual ~Win32BaseWindow();
63
64virtual ULONG MsgCreate(HWND hwndFrame, HWND hwndClient);
65 ULONG MsgQuit();
66 ULONG MsgClose();
67 ULONG MsgDestroy();
68virtual ULONG MsgEnable(BOOL fEnable);
69 ULONG MsgShow(BOOL fShow);
70 ULONG MsgPosChanging(LPARAM lp);
71 ULONG MsgPosChanged(LPARAM lp);
72 ULONG MsgMove(ULONG x, ULONG y);
73 ULONG MsgHitTest(ULONG x, ULONG y);
74 ULONG MsgSize(ULONG width, ULONG height, BOOL fMinimize, BOOL fMaximize);
75virtual ULONG MsgActivate(BOOL fActivate, BOOL fMinimized, HWND hwnd);
76 ULONG MsgSetFocus(HWND hwnd);
77 ULONG MsgKillFocus(HWND hwnd);
78 ULONG MsgTimer(ULONG TimerID);
79 ULONG MsgSysTimer(ULONG TimerID);
80 ULONG MsgScroll(ULONG msg, ULONG scrollCode, ULONG scrollPos);
81 ULONG MsgCommand(ULONG cmd, ULONG Id, HWND hwnd);
82 ULONG MsgSysCommand(ULONG win32sc, ULONG x, ULONG y);
83 ULONG MsgChar(ULONG cmd, ULONG repeatcnt, ULONG scancode, ULONG vkey, ULONG keyflags);
84 ULONG MsgKeyUp (ULONG repeatCount, ULONG scancode, ULONG virtualKey);
85 ULONG MsgKeyDown (ULONG repeatCount, ULONG scancode, ULONG virtualKey, BOOL keyWasPressed);
86 ULONG MsgSysKeyUp (ULONG repeatCount, ULONG scancode, ULONG virtualKey);
87 ULONG MsgSysKeyDown (ULONG repeatCount, ULONG scancode, ULONG virtualKey, BOOL keyWasPressed);
88 ULONG MsgButton(ULONG msg, ULONG ncx, ULONG ncy, ULONG clx, ULONG cly);
89 ULONG MsgMouseMove(ULONG keystate, ULONG x, ULONG y);
90 ULONG MsgPaint(ULONG tmp1, BOOL select = TRUE);
91 ULONG MsgEraseBackGround(HDC hdc);
92 ULONG MsgSetText(LPSTR lpsz, LONG cch);
93 ULONG MsgGetTextLength();
94 char *MsgGetText();
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 CanReceiveSizeMsgs() { return !fNoSizeMsg; };
169 BOOL IsWindowDestroyed() { return fIsDestroyed; };
170 BOOL IsWindowEnabled();
171 BOOL IsWindowVisible();
172 BOOL IsUnicode() { return isUnicode; };
173 BOOL GetWindowRect(PRECT pRect);
174 int GetWindowTextLength();
175 int GetWindowTextA(LPSTR lpsz, int cch);
176 int GetWindowTextW(LPWSTR lpsz, int cch);
177 BOOL SetWindowTextA(LPSTR lpsz);
178 BOOL SetWindowTextW(LPWSTR lpsz);
179 BOOL hasWindowName(LPSTR wndname, BOOL fUnicode = 0);
180Win32WndClass *getClass() { return windowClass; };
181 char *getWindowNameA() { return windowNameA; };
182Win32BaseWindow *getOwner() { return owner; };
183
184Win32BaseWindow *getTopParent();
185 SCROLLBAR_INFO *getScrollInfo(int nBar);
186 HWND getVertScrollHandle() { return hwndVertScroll; };
187 HWND getHorzScrollHandle() { return hwndHorzScroll; };
188 VOID subclassScrollBars(BOOL subHorz,BOOL subVert);
189
190 LRESULT SendMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
191 LRESULT SendMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
192 BOOL PostMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
193 BOOL PostMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
194 LRESULT DefWindowProcA(UINT msg, WPARAM wParam, LPARAM lParam);
195 LRESULT DefWindowProcW(UINT msg, WPARAM wParam, LPARAM lParam);
196
197 LRESULT DefWndControlColor(UINT ctlType, HDC hdc);
198
199 void NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam);
200
201Win32BaseWindow *FindWindowById(int id);
202
203 static HWND FindWindowEx(HWND hwndParent, HWND hwndChildAfter, LPSTR lpszClass, LPSTR lpszWindow,
204 BOOL fUnicode = 0);
205
206 BOOL EnumChildWindows(WNDENUMPROC lpfn, LPARAM lParam);
207
208 static HWND Win32ToOS2Handle(HWND hwnd);
209 static HWND Win32ToOS2FrameHandle(HWND hwnd);
210 static HWND OS2ToWin32Handle(HWND hwnd);
211
212static Win32BaseWindow *GetWindowFromHandle(HWND hwnd);
213static Win32BaseWindow *GetWindowFromOS2Handle(HWND hwnd);
214static Win32BaseWindow *GetWindowFromOS2FrameHandle(HWND hwnd);
215
216 PVOID getOldFrameProc() { return pOldFrameProc; };
217 VOID setOldFrameProc(PVOID aOldFrameProc) { pOldFrameProc = aOldFrameProc; };
218 ULONG getBorderWidth() { return borderWidth; };
219 ULONG getBorderHeight() { return borderHeight; };
220
221static void NC_AdjustRectInner(LPRECT rect, DWORD style, DWORD exStyle);
222static void NC_AdjustRectOuter(LPRECT rect, DWORD style, BOOL menu, DWORD exStyle);
223static BOOL WindowNeedsWMBorder( DWORD style, DWORD exStyle );
224
225 PVOID getOldWndProc() { return pOldWndProc; }
226 VOID setOldWndProc(PVOID aOldWndProc) { pOldWndProc = aOldWndProc; }
227 BOOL isSubclassedOS2Wnd() { return fIsSubclassedOS2Wnd; };
228
229protected:
230#ifndef OS2_INCLUDED
231 BOOL CreateWindowExA(CREATESTRUCTA *lpCreateStruct, ATOM classAtom);
232#endif
233 LRESULT SendInternalMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
234 LRESULT SendInternalMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
235 void Init();
236 void setExtendedKey(ULONG virtualkey, ULONG *lParam);
237
238 HWND OS2Hwnd;
239 HWND OS2HwndFrame;
240 HWND OS2HwndMenu;
241 HWND Win32Hwnd;
242 BOOL isUnicode;
243
244 int posx, posy, width, height;
245
246 // values normally contained in the standard window words
247 ULONG dwExStyle; //GWL_EXSTYLE
248 ULONG dwStyle; //GWL_STYLE
249 WNDPROC win32wndproc; //GWL_WNDPROC
250 ULONG hInstance; //GWL_HINSTANCE
251//Moved in ChildWindow class
252///// Win32BaseWindow *parent; //GWL_HWNDPARENT
253 ULONG windowId; //GWL_ID
254 ULONG userData; //GWL_USERDATA
255
256 HWND hwndLinkAfter;
257 DWORD flags;
258 DWORD lastHitTestVal; //Last value returned by WM_NCHITTEST handler
259
260 BOOL isIcon;
261 BOOL fFirstShow;
262 BOOL fIsDialog;
263 BOOL fInternalMsg; //Used to distinguish between messages
264 //sent by PM and those sent by apps
265 BOOL fNoSizeMsg;
266 BOOL fIsDestroyed;
267 BOOL fCreated;
268
269 PVOID pOldFrameProc;
270 ULONG borderWidth;
271 ULONG borderHeight;
272
273 PVOID pOldWndProc;
274 BOOL fIsSubclassedOS2Wnd; //subclassed OS/2 window: Netscape plug-in/scrollbar
275
276 Win32BaseWindow *owner;
277
278 Win32Resource *acceltableResource;
279 Win32Resource *iconResource;
280
281 char *windowNameA;
282 WCHAR *windowNameW;
283 ULONG wndNameLength; //including 0 terminator
284
285 ULONG *userWindowLong;
286 ULONG nrUserWindowLong;
287
288 RECT rectWindow;
289 RECT rectClient;
290
291CREATESTRUCTA *tmpcs; //temporary pointer to CREATESTRUCT used in CreateWindowEx
292 ULONG sw; //set in CreateWindowExA, used in MsgCreate method
293
294SCROLLBAR_INFO *vertScrollInfo;
295SCROLLBAR_INFO *horzScrollInfo;
296 HWND hwndHorzScroll; //os/2 handle
297 HWND hwndVertScroll; //os/2 handle
298
299Win32WndClass *windowClass;
300
301static GenericObject *windows;
302
303private:
304#ifndef OS2_INCLUDED
305 void GetMinMaxInfo(POINT *maxSize, POINT *maxPos, POINT *minTrack, POINT *maxTrack );
306 LONG HandleWindowPosChanging(WINDOWPOS *winpos);
307 LONG HandleSysCommand(WPARAM wParam, POINT *pt32);
308
309 LONG SendNCCalcSize(BOOL calcValidRect,
310 RECT *newWindowRect, RECT *oldWindowRect,
311 RECT *oldClientRect, WINDOWPOS *winpos,
312 RECT *newClientRect );
313
314 LONG NCHandleCalcSize(WPARAM wParam, NCCALCSIZE_PARAMS *ncsize);
315
316 LRESULT SendInternalMessage(ULONG msg, WPARAM wParam, LPARAM lParam)
317 {
318 if(isUnicode)
319 return SendInternalMessageW(msg, wParam, lParam);
320 else return SendInternalMessageA(msg, wParam, lParam);
321 }
322#endif
323
324public:
325 void SetFakeOpen32() { WinSetDAXData (OS2Hwnd, &fakeWinBase); }
326 void RemoveFakeOpen32() { WinSetDAXData (OS2Hwnd, NULL); }
327
328 fakeOpen32WinBaseClass fakeWinBase;
329
330 BOOL isOwnDC() { return (windowClass && windowClass->getStyle() & CS_OWNDC_W); }
331 HDC getOwnDC() { return ownDC; }
332 void setOwnDC(HDC hdc) { ownDC = hdc; }
333protected:
334 HDC ownDC;
335
336 ULONG EraseBkgndFlag:1,
337 PSEraseFlag:1,
338 SupressEraseFlag:1,
339 filler:29;
340public:
341 VOID setEraseBkgnd (BOOL erase, BOOL PSErase = FALSE)
342 { EraseBkgndFlag = erase; PSEraseFlag = PSErase; }
343 VOID setSupressErase (BOOL erase = FALSE)
344 { SupressEraseFlag = erase; }
345 BOOL isEraseBkgnd() { return EraseBkgndFlag; }
346 BOOL isPSErase() { return EraseBkgndFlag | PSEraseFlag; }
347 BOOL isSupressErase() { return SupressEraseFlag; }
348};
349
350
351#define BUTTON_LEFTDOWN 0
352#define BUTTON_LEFTUP 1
353#define BUTTON_LEFTDBLCLICK 2
354#define BUTTON_RIGHTUP 3
355#define BUTTON_RIGHTDOWN 4
356#define BUTTON_RIGHTDBLCLICK 5
357#define BUTTON_MIDDLEUP 6
358#define BUTTON_MIDDLEDOWN 7
359#define BUTTON_MIDDLEDBLCLICK 8
360
361#define WMMOVE_LBUTTON 1
362#define WMMOVE_MBUTTON 2
363#define WMMOVE_RBUTTON 4
364#define WMMOVE_CTRL 8
365#define WMMOVE_SHIFT 16
366
367
368#define CMD_MENU 1
369#define CMD_CONTROL 2
370#define CMD_ACCELERATOR 3
371
372#define KEY_ALTDOWN 1
373#define KEY_PREVDOWN 2
374#define KEY_UP 4
375#define KEY_DEADKEY 8
376
377#endif //__cplusplus
378
379#endif //__WIN32WNDBASE_H__
Note: See TracBrowser for help on using the repository browser.