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

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

Dialog fixes + ported Wine apis

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