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

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

Desktop enable bugfix + CTLCOLOR Wine port

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