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

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

dlg fix, keyboard additions, + misc other things

File size: 15.7 KB
Line 
1/* $Id: win32wbase.h,v 1.43 1999-11-11 13:17:32 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
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 DWORD getWindowContextHelpId() { return contextHelpId; };
111 void setWindowContextHelpId(DWORD id){ contextHelpId = id; };
112
113 BOOL isFrameWindow();
114virtual BOOL isMDIClient();
115virtual BOOL isMDIChild();
116
117Win32BaseWindow *getParent() { return (Win32BaseWindow *)ChildWindow::GetParent(); };
118 void setParent(Win32BaseWindow *pwindow) { ChildWindow::SetParent((ChildWindow *)pwindow); };
119 WNDPROC getWindowProc() { return win32wndproc; };
120 void setWindowProc(WNDPROC newproc) { win32wndproc = newproc; };
121 DWORD getWindowId() { return windowId; };
122 void setWindowId(DWORD id);
123 ULONG getWindowHeight() { return rectClient.bottom - rectClient.top; };
124 ULONG getWindowWidth() { return rectClient.right - rectClient.left; };
125 BOOL isChild();
126 PRECT getClientRect() { return &rectClient; };
127 void setClientRect(PRECT rect) { rectClient = *rect; };
128 PRECT getWindowRect() { return &rectWindow; };
129 void setClientRect(LONG left, LONG top, LONG right, LONG bottom)
130 {
131 rectClient.left = left; rectClient.top = top;
132 rectClient.right = right; rectClient.bottom = bottom;
133 };
134 void setWindowRect(LONG left, LONG top, LONG right, LONG bottom)
135 {
136 rectWindow.left = left; rectWindow.top = top;
137 rectWindow.right = right; rectWindow.bottom = bottom;
138 };
139 void setWindowRect(PRECT rect) { rectWindow = *rect; };
140 DWORD getFlags() { return flags; };
141 void setFlags(DWORD newflags) { flags = newflags; };
142
143 HACCEL GetAccelTable() { return (HACCEL) acceltableResource; };
144 BOOL SetAccelTable(ULONG hAccel);
145
146 HMENU GetMenu() { return (HMENU) OS2HwndMenu; };
147 BOOL SetMenu(ULONG hMenu);
148
149 BOOL SetIcon(HICON hIcon);
150 HICON GetIcon() { return (HICON) iconResource; };
151
152 BOOL ShowWindow(ULONG nCmdShow);
153 BOOL SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags);
154 BOOL SetWindowPlacement(WINDOWPLACEMENT *winpos);
155 BOOL DestroyWindow();
156 HWND SetActiveWindow();
157 HWND GetParent();
158 HWND SetParent(HWND hwndNewParent);
159 BOOL IsChild(HWND hwndParent);
160 HWND GetTopWindow();
161Win32BaseWindow *GetTopParent();
162 BOOL UpdateWindow();
163 BOOL IsIconic();
164 HWND GetWindow(UINT uCmd);
165 virtual BOOL EnableWindow(BOOL fEnable);
166 BOOL CloseWindow();
167 static HWND GetActiveWindow();
168 //Window handle has already been verified, so just return true
169 BOOL IsWindow() { return TRUE; };
170 BOOL IsDialog() { return fIsDialog; };
171 BOOL IsModalDialog() { return fIsModalDialog; };
172 BOOL IsModalDialogOwner() { return fIsModalDialogOwner; };
173 VOID setModalDialogOwner(BOOL fMDO) { fIsModalDialogOwner = fMDO; };
174 VOID setOS2HwndModalDialog(HWND aHwnd) { OS2HwndModalDialog = aHwnd; };
175 HWND getOS2HwndModalDialog() { return OS2HwndModalDialog; };
176 BOOL CanReceiveSizeMsgs() { return !fNoSizeMsg; };
177 BOOL IsWindowDestroyed() { return fIsDestroyed; };
178 BOOL IsWindowEnabled();
179 BOOL IsWindowVisible();
180 BOOL IsUnicode() { return isUnicode; };
181 BOOL GetWindowRect(PRECT pRect);
182 int GetWindowTextLength();
183 int GetWindowTextA(LPSTR lpsz, int cch);
184 int GetWindowTextW(LPWSTR lpsz, int cch);
185 BOOL SetWindowTextA(LPSTR lpsz);
186 BOOL SetWindowTextW(LPWSTR lpsz);
187 BOOL hasWindowName(LPSTR wndname, BOOL fUnicode = 0);
188Win32WndClass *getClass() { return windowClass; };
189 char *getWindowNameA() { return windowNameA; };
190Win32BaseWindow *getOwner() { return owner; };
191
192 SCROLLBAR_INFO *getScrollInfo(int nBar);
193 HWND getVertScrollHandle() { return hwndVertScroll; };
194 VOID setVertScrollHandle(HWND newHandle) { hwndVertScroll = newHandle; }
195 HWND getHorzScrollHandle() { return hwndHorzScroll; };
196 VOID setHorzScrollHandle(HWND newHandle) { hwndHorzScroll = newHandle; }
197 VOID subclassScrollBars(BOOL subHorz,BOOL subVert);
198 BOOL showScrollBars(BOOL changeHorz,BOOL changeVert,BOOL fShow);
199
200 LRESULT SendMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
201 LRESULT SendMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
202 BOOL PostMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
203 BOOL PostMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
204 LRESULT DefWindowProcA(UINT msg, WPARAM wParam, LPARAM lParam);
205 LRESULT DefWindowProcW(UINT msg, WPARAM wParam, LPARAM lParam);
206
207 LRESULT DefWndControlColor(UINT ctlType, HDC hdc);
208
209 void NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam);
210
211Win32BaseWindow *FindWindowById(int id);
212
213 static HWND FindWindowEx(HWND hwndParent, HWND hwndChildAfter, LPSTR lpszClass, LPSTR lpszWindow,
214 BOOL fUnicode = 0);
215
216 BOOL EnumChildWindows(WNDENUMPROC lpfn, LPARAM lParam);
217
218 HWND getNextDlgTabItem(HWND hwndCtrl, BOOL fPrevious);
219 HWND getNextDlgGroupItem(HWND hwndCtrl, BOOL fPrevious);
220
221 static HWND Win32ToOS2Handle(HWND hwnd);
222 static HWND Win32ToOS2FrameHandle(HWND hwnd);
223 static HWND OS2ToWin32Handle(HWND hwnd);
224
225static Win32BaseWindow *GetWindowFromHandle(HWND hwnd);
226static Win32BaseWindow *GetWindowFromOS2Handle(HWND hwnd);
227static Win32BaseWindow *GetWindowFromOS2FrameHandle(HWND hwnd);
228
229 static void DestroyAll();
230
231 PVOID getOldFrameProc() { return pOldFrameProc; };
232 VOID setOldFrameProc(PVOID aOldFrameProc) { pOldFrameProc = aOldFrameProc; };
233 ULONG getBorderWidth() { return borderWidth; };
234 ULONG getBorderHeight() { return borderHeight; };
235
236static void NC_AdjustRectInner(LPRECT rect, DWORD style, DWORD exStyle);
237static void NC_AdjustRectOuter(LPRECT rect, DWORD style, BOOL menu, DWORD exStyle);
238static BOOL WindowNeedsWMBorder( DWORD style, DWORD exStyle );
239
240 PVOID getOldWndProc() { return pOldWndProc; }
241 VOID setOldWndProc(PVOID aOldWndProc) { pOldWndProc = aOldWndProc; }
242 BOOL isSubclassedOS2Wnd() { return fIsSubclassedOS2Wnd; };
243
244protected:
245#ifndef OS2_INCLUDED
246 BOOL CreateWindowExA(CREATESTRUCTA *lpCreateStruct, ATOM classAtom);
247#endif
248 LRESULT SendInternalMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
249 LRESULT SendInternalMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
250 void Init();
251 void setExtendedKey(ULONG virtualkey, ULONG *lParam);
252
253 HWND OS2Hwnd;
254 HWND OS2HwndFrame;
255 HWND OS2HwndMenu;
256 HWND Win32Hwnd;
257 BOOL isUnicode;
258
259 int posx, posy, width, height;
260
261 // values normally contained in the standard window words
262 ULONG dwExStyle; //GWL_EXSTYLE
263 ULONG dwStyle; //GWL_STYLE
264 WNDPROC win32wndproc; //GWL_WNDPROC
265 ULONG hInstance; //GWL_HINSTANCE
266//Moved in ChildWindow class
267///// Win32BaseWindow *parent; //GWL_HWNDPARENT
268 ULONG windowId; //GWL_ID
269 ULONG userData; //GWL_USERDATA
270
271 HWND hwndLinkAfter;
272 DWORD flags;
273 DWORD contextHelpId;
274 LONG lastHitTestVal; //Last value returned by WM_NCHITTEST handler
275
276 BOOL isIcon;
277 BOOL fFirstShow;
278 BOOL fIsDialog;
279 BOOL fIsModalDialog;
280 BOOL fIsModalDialogOwner;
281 HWND OS2HwndModalDialog;
282 BOOL fInternalMsg; //Used to distinguish between messages
283 //sent by PM and those sent by apps
284 BOOL fNoSizeMsg;
285 BOOL fIsDestroyed;
286 BOOL fCreated;
287
288 PVOID pOldFrameProc;
289 ULONG borderWidth;
290 ULONG borderHeight;
291
292 PVOID pOldWndProc;
293 BOOL fIsSubclassedOS2Wnd; //subclassed OS/2 window: Netscape plug-in/scrollbar
294
295 Win32BaseWindow *owner;
296
297 Win32Resource *acceltableResource;
298 Win32Resource *iconResource;
299
300 char *windowNameA;
301 WCHAR *windowNameW;
302 ULONG wndNameLength; //including 0 terminator
303
304 ULONG *userWindowLong;
305 ULONG nrUserWindowLong;
306
307 RECT rectWindow;
308 RECT rectClient;
309
310CREATESTRUCTA *tmpcs; //temporary pointer to CREATESTRUCT used in CreateWindowEx
311 ULONG sw; //set in CreateWindowExA, used in MsgCreate method
312
313SCROLLBAR_INFO *vertScrollInfo;
314SCROLLBAR_INFO *horzScrollInfo;
315 HWND hwndHorzScroll; //os/2 handle
316 HWND hwndVertScroll; //os/2 handle
317
318Win32WndClass *windowClass;
319
320static GenericObject *windows;
321
322private:
323#ifndef OS2_INCLUDED
324 void GetMinMaxInfo(POINT *maxSize, POINT *maxPos, POINT *minTrack, POINT *maxTrack );
325 LONG HandleWindowPosChanging(WINDOWPOS *winpos);
326 LONG HandleSysCommand(WPARAM wParam, POINT *pt32);
327
328 LONG SendNCCalcSize(BOOL calcValidRect,
329 RECT *newWindowRect, RECT *oldWindowRect,
330 RECT *oldClientRect, WINDOWPOS *winpos,
331 RECT *newClientRect );
332
333 LONG NCHandleCalcSize(WPARAM wParam, NCCALCSIZE_PARAMS *ncsize);
334
335 LRESULT SendInternalMessage(ULONG msg, WPARAM wParam, LPARAM lParam)
336 {
337 if(isUnicode)
338 return SendInternalMessageW(msg, wParam, lParam);
339 else return SendInternalMessageA(msg, wParam, lParam);
340 }
341#endif
342
343public:
344 void SetFakeOpen32() { WinSetDAXData (OS2Hwnd, &fakeWinBase); }
345 void RemoveFakeOpen32() { WinSetDAXData (OS2Hwnd, NULL); }
346
347 fakeOpen32WinBaseClass fakeWinBase;
348
349 BOOL isOwnDC() { return (windowClass && windowClass->getStyle() & CS_OWNDC_W); }
350 HDC getOwnDC() { return ownDC; }
351 void setOwnDC(HDC hdc) { ownDC = hdc; }
352protected:
353 HDC ownDC;
354
355 ULONG EraseBkgndFlag:1,
356 PSEraseFlag:1,
357 SupressEraseFlag:1,
358 filler:29;
359public:
360 VOID setEraseBkgnd (BOOL erase, BOOL PSErase = FALSE)
361 { EraseBkgndFlag = erase; PSEraseFlag = PSErase; }
362 VOID setSupressErase (BOOL erase = FALSE)
363 { SupressEraseFlag = erase; }
364 BOOL isEraseBkgnd() { return EraseBkgndFlag; }
365 BOOL isPSErase() { return EraseBkgndFlag | PSEraseFlag; }
366 BOOL isSupressErase() { return SupressEraseFlag; }
367};
368
369
370#define BUTTON_LEFTDOWN 0
371#define BUTTON_LEFTUP 1
372#define BUTTON_LEFTDBLCLICK 2
373#define BUTTON_RIGHTUP 3
374#define BUTTON_RIGHTDOWN 4
375#define BUTTON_RIGHTDBLCLICK 5
376#define BUTTON_MIDDLEUP 6
377#define BUTTON_MIDDLEDOWN 7
378#define BUTTON_MIDDLEDBLCLICK 8
379
380#define WMMOVE_LBUTTON 1
381#define WMMOVE_MBUTTON 2
382#define WMMOVE_RBUTTON 4
383#define WMMOVE_CTRL 8
384#define WMMOVE_SHIFT 16
385
386
387#define CMD_MENU 1
388#define CMD_CONTROL 2
389#define CMD_ACCELERATOR 3
390
391#define KEY_ALTDOWN 1
392#define KEY_PREVDOWN 2
393#define KEY_UP 4
394#define KEY_DEADKEY 8
395
396#endif //__cplusplus
397
398#endif //__WIN32WNDBASE_H__
Note: See TracBrowser for help on using the repository browser.