source: trunk/src/user32/new/win32wbase.h@ 820

Last change on this file since 820 was 819, checked in by dengert, 26 years ago

begin DAXifying windows

File size: 11.3 KB
Line 
1/* $Id: win32wbase.h,v 1.4 1999-09-04 17:56:41 dengert 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
24class Win32BaseWindow;
25
26#define OFFSET_WIN32WNDPTR 0
27#define OFFSET_WIN32PM_MAGIC 4
28#define OFFSET_WIN32PM_SHAREDMEM 8
29#define NROF_WIN32WNDBYTES 12
30
31#define WIN32PM_MAGIC 0x12345678
32#define CheckMagicDword(a) (a==WIN32PM_MAGIC)
33
34#define WIN32APP_USERMSGBASE 0x1000
35
36typedef struct {
37 USHORT cb;
38 Win32BaseWindow *win32wnd;
39 ULONG win32CreateStruct; //or dialog create dword
40} CUSTOMWNDDATA;
41
42typedef struct
43{
44 ULONG Msg;
45 ULONG wParam;
46 ULONG lParam;
47} POSTMSG_PACKET;
48
49#define WM_WIN32_POSTMESSAGEA 0x4000
50#define WM_WIN32_POSTMESSAGEW 0x4001
51
52class Win32BaseWindow : public GenericObject, protected ChildWindow
53{
54public:
55 DWORD magic;
56
57 Win32BaseWindow(DWORD objType);
58 Win32BaseWindow(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode);
59virtual ~Win32BaseWindow();
60
61virtual ULONG MsgCreate(HWND hwndOS2, ULONG initParam);
62 ULONG MsgQuit();
63 ULONG MsgClose();
64 ULONG MsgDestroy();
65 ULONG MsgEnable(BOOL fEnable);
66 ULONG MsgShow(BOOL fShow);
67 ULONG MsgPosChanging(LPARAM lp);
68 ULONG MsgPosChanged(LPARAM lp);
69 ULONG MsgMove(ULONG x, ULONG y);
70 ULONG MsgHitTest(ULONG x, ULONG y);
71 ULONG MsgSize(ULONG width, ULONG height, BOOL fMinimize, BOOL fMaximize);
72 ULONG MsgActivate(BOOL fActivate, HWND hwnd);
73 ULONG MsgSetFocus(HWND hwnd);
74 ULONG MsgKillFocus(HWND hwnd);
75 ULONG MsgCommand(ULONG cmd, ULONG Id, HWND hwnd);
76 ULONG MsgSysCommand(ULONG win32sc, ULONG x, ULONG y);
77 ULONG MsgChar(ULONG cmd, ULONG repeatcnt, ULONG scancode, ULONG vkey, ULONG keyflags);
78 ULONG MsgButton(ULONG msg, ULONG ncx, ULONG ncy, ULONG clx, ULONG cly);
79 ULONG MsgMouseMove(ULONG keystate, ULONG x, ULONG y);
80 ULONG MsgPaint(ULONG tmp1, ULONG tmp2);
81 ULONG MsgEraseBackGround(HDC hdc);
82 ULONG MsgSetText(LPSTR lpsz, LONG cch);
83 ULONG MsgGetTextLength();
84 char *MsgGetText();
85
86virtual LONG SetWindowLongA(int index, ULONG value);
87virtual ULONG GetWindowLongA(int index);
88virtual WORD SetWindowWord(int index, WORD value);
89virtual WORD GetWindowWord(int index);
90
91 DWORD getStyle() { return dwStyle; };
92 void setStyle(DWORD newstyle) { dwStyle = newstyle; };
93 DWORD getExStyle() { return dwExStyle; };
94 void setExStyle(DWORD newexstyle) { dwExStyle = newexstyle; };
95 HWND getWindowHandle() { return Win32Hwnd; };
96 HWND getOS2WindowHandle() { return OS2Hwnd; };
97 HWND getOS2FrameWindowHandle() { return OS2HwndFrame; };
98 Win32WndClass *getWindowClass() { return windowClass; };
99
100 BOOL isFrameWindow() { return OS2Hwnd != OS2HwndFrame; };
101Win32BaseWindow *getParent() { return (Win32BaseWindow *)ChildWindow::GetParent(); };
102 void setParent(Win32BaseWindow *pwindow) { ChildWindow::SetParent((ChildWindow *)pwindow); };
103 WNDPROC getWindowProc() { return win32wndproc; };
104 void setWindowProc(WNDPROC newproc) { win32wndproc = newproc; };
105 DWORD getWindowId() { return windowId; };
106 void setWindowId(DWORD id) { windowId = id; };
107 ULONG getWindowHeight() { return rectClient.bottom - rectClient.top; };
108 BOOL isChild();
109 PRECT getClientRect() { return &rectClient; };
110 void setClientRect(PRECT rect) { rectClient = *rect; };
111 PRECT getWindowRect() { return &rectWindow; };
112 void setClientRect(LONG left, LONG top, LONG right, LONG bottom)
113 {
114 rectClient.left = left; rectClient.top = top;
115 rectClient.right = right; rectClient.bottom = bottom;
116 };
117 void setWindowRect(LONG left, LONG top, LONG right, LONG bottom)
118 {
119 rectWindow.left = left; rectWindow.top = top;
120 rectWindow.right = right; rectWindow.bottom = bottom;
121 };
122 void setWindowRect(PRECT rect) { rectWindow = *rect; };
123
124 DWORD getFlags() { return flags; };
125 void setFlags(DWORD newflags) { flags = newflags; };
126
127 HACCEL GetAccelTable() { return (HACCEL) acceltableResource; };
128 BOOL SetAccelTable(ULONG hAccel);
129
130 HMENU GetMenu() { return (HMENU) menuResource; };
131 BOOL SetMenu(ULONG hMenu);
132
133 BOOL SetIcon(HICON hIcon);
134 HICON GetIcon() { return (HICON) iconResource; };
135
136 BOOL ShowWindow(ULONG nCmdShow);
137 BOOL SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags);
138 BOOL DestroyWindow();
139 HWND SetActiveWindow();
140 HWND GetParent();
141 HWND SetParent(HWND hwndNewParent);
142 BOOL IsChild(HWND hwndParent);
143 HWND GetTopWindow();
144 BOOL UpdateWindow();
145 BOOL IsIconic();
146 HWND GetWindow(UINT uCmd);
147 BOOL EnableWindow(BOOL fEnable);
148 BOOL CloseWindow();
149 static HWND GetActiveWindow();
150 BOOL IsWindow();
151 BOOL IsWindowEnabled();
152 BOOL IsWindowVisible();
153 BOOL IsUnicode() { return isUnicode; };
154
155 BOOL GetWindowRect(PRECT pRect);
156 int GetWindowTextLengthA();
157 int GetWindowTextA(LPSTR lpsz, int cch);
158 BOOL SetWindowText(LPSTR lpsz);
159 BOOL hasWindowName(LPSTR wndname, BOOL fUnicode = 0);
160Win32WndClass *getClass() { return windowClass; };
161 char *getWindowNameA() { return windowNameA; };
162Win32BaseWindow *getOwner() { return owner; };
163
164 LRESULT SendMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
165 LRESULT SendMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
166 BOOL PostMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
167 BOOL PostMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
168 LRESULT DefWindowProcA(UINT msg, WPARAM wParam, LPARAM lParam);
169 LRESULT DefWindowProcW(UINT msg, WPARAM wParam, LPARAM lParam);
170
171 void NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam);
172
173 static HWND FindWindowEx(HWND hwndParent, HWND hwndChildAfter, LPSTR lpszClass, LPSTR lpszWindow,
174 BOOL fUnicode = 0);
175
176 static HWND Win32ToOS2Handle(HWND hwnd)
177 {
178 Win32BaseWindow *window = GetWindowFromHandle(hwnd);
179
180 if(window) {
181 return window->getOS2WindowHandle();
182 }
183 else return hwnd; //OS/2 window handle
184 }
185
186 static HWND OS2ToWin32Handle(HWND hwnd)
187 {
188 Win32BaseWindow *window = GetWindowFromOS2Handle(hwnd);
189
190 if(window) {
191 return window->getWindowHandle();
192 }
193 else return hwnd; //OS/2 window handle
194 }
195
196static Win32BaseWindow *GetWindowFromHandle(HWND hwnd);
197static Win32BaseWindow *GetWindowFromOS2Handle(HWND hwnd);
198
199protected:
200 LRESULT SendInternalMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
201 LRESULT SendInternalMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
202 void Init();
203
204 HWND OS2Hwnd;
205 HWND OS2HwndFrame;
206 HWND OS2HwndMenu;
207 HWND Win32Hwnd;
208 BOOL isUnicode;
209
210 int posx, posy, width, height;
211
212 // values normally contained in the standard window words
213 ULONG dwExStyle; //GWL_EXSTYLE
214 ULONG dwStyle; //GWL_STYLE
215 WNDPROC win32wndproc; //GWL_WNDPROC
216 ULONG hInstance; //GWL_HINSTANCE
217//Moved in ChildWindow class
218///// Win32BaseWindow *parent; //GWL_HWNDPARENT
219 ULONG windowId; //GWL_ID
220 ULONG userData; //GWL_USERDATA
221
222 HWND hwndLinkAfter;
223 DWORD flags;
224 DWORD lastHitTestVal; //Last value returned by WM_NCHITTEST handler
225
226 BOOL isIcon;
227 BOOL fCreated;
228 BOOL fFirstShow;
229
230 Win32BaseWindow *owner;
231
232 Win32Resource *acceltableResource;
233 Win32Resource *menuResource;
234 Win32Resource *iconResource;
235
236 char *windowNameA;
237 WCHAR *windowNameW;
238 ULONG wndNameLength; //including 0 terminator
239
240 ULONG *userWindowLong;
241 ULONG nrUserWindowLong;
242
243 RECT rectWindow;
244 RECT rectClient;
245
246Win32WndClass *windowClass;
247
248static GenericObject *windows;
249
250private:
251#ifndef OS2_INCLUDED
252 BOOL CreateWindowExA(CREATESTRUCTA *lpCreateStruct, ATOM classAtom);
253
254 void GetMinMaxInfo(POINT *maxSize, POINT *maxPos, POINT *minTrack, POINT *maxTrack );
255
256 LONG SendNCCalcSize(BOOL calcValidRect,
257 RECT *newWindowRect, RECT *oldWindowRect,
258 RECT *oldClientRect, WINDOWPOS *winpos,
259 RECT *newClientRect );
260
261 LRESULT SendInternalMessage(ULONG msg, WPARAM wParam, LPARAM lParam)
262 {
263 if(isUnicode)
264 return SendInternalMessageW(msg, wParam, lParam);
265 else return SendInternalMessageA(msg, wParam, lParam);
266 }
267#endif
268
269public:
270 void SetFakeOpen32() { WinSetDAXData (OS2Hwnd, &fakeWinBase); }
271 void RemoveFakeOpen32() { WinSetDAXData (OS2Hwnd, NULL); }
272
273 fakeOpen32WinBaseClass fakeWinBase;
274};
275
276
277#define BUTTON_LEFTDOWN 0
278#define BUTTON_LEFTUP 1
279#define BUTTON_LEFTDBLCLICK 2
280#define BUTTON_RIGHTUP 3
281#define BUTTON_RIGHTDOWN 4
282#define BUTTON_RIGHTDBLCLICK 5
283#define BUTTON_MIDDLEUP 6
284#define BUTTON_MIDDLEDOWN 7
285#define BUTTON_MIDDLEDBLCLICK 8
286
287#define WMMOVE_LBUTTON 1
288#define WMMOVE_MBUTTON 2
289#define WMMOVE_RBUTTON 4
290#define WMMOVE_CTRL 8
291#define WMMOVE_SHIFT 16
292
293
294#define CMD_MENU 1
295#define CMD_CONTROL 2
296#define CMD_ACCELERATOR 3
297
298#define WIN32SC_SIZE 0xf000
299#define WIN32SC_MOVE 0xf010
300#define WIN32SC_MINIMIZE 0xf020
301#define WIN32SC_MAXIMIZE 0xf030
302#define WIN32SC_NEXTWINDOW 0xf040
303#define WIN32SC_PREVWINDOW 0xf050
304#define WIN32SC_CLOSE 0xf060
305#define WIN32SC_VSCROLL 0xf070
306#define WIN32SC_HSCROLL 0xf080
307#define WIN32SC_MOUSEMENU 0xf090
308#define WIN32SC_KEYMENU 0xf100
309#define WIN32SC_ARRANGE 0xf110
310#define WIN32SC_RESTORE 0xf120
311#define WIN32SC_TASKLIST 0xf130
312#define WIN32SC_SCREENSAVE 0xf140
313#define WIN32SC_HOTKEY 0xf150
314
315#define KEY_ALTDOWN 1
316#define KEY_PREVDOWN 2
317#define KEY_UP 4
318#define KEY_DEADKEY 8
319
320#endif //__cplusplus
321
322#endif //__WIN32WNDBASE_H__
Note: See TracBrowser for help on using the repository browser.