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

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

MDI child/client changes

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