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

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

Added MDI class + ChildWindowFromPointEx by Rene Pronk

File size: 10.9 KB
Line 
1/* $Id: win32wbase.h,v 1.2 1999-08-31 10:36:23 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);
159
160 LRESULT SendMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
161 LRESULT SendMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
162 BOOL PostMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
163 BOOL PostMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
164 LRESULT DefWindowProcA(UINT msg, WPARAM wParam, LPARAM lParam);
165 LRESULT DefWindowProcW(UINT msg, WPARAM wParam, LPARAM lParam);
166
167 void NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam);
168
169Win32WndClass *getClass() { return windowClass; };
170
171 static HWND FindWindowEx(HWND hwndParent, HWND hwndChildAfter, LPSTR lpszClass, LPSTR lpszWindow,
172 BOOL fUnicode = 0);
173
174 static HWND Win32ToOS2Handle(HWND hwnd)
175 {
176 Win32BaseWindow *window = GetWindowFromHandle(hwnd);
177
178 if(window) {
179 return window->getOS2WindowHandle();
180 }
181 else return hwnd; //OS/2 window handle
182 }
183
184 static HWND OS2ToWin32Handle(HWND hwnd)
185 {
186 Win32BaseWindow *window = GetWindowFromOS2Handle(hwnd);
187
188 if(window) {
189 return window->getWindowHandle();
190 }
191 else return hwnd; //OS/2 window handle
192 }
193
194static Win32BaseWindow *GetWindowFromHandle(HWND hwnd);
195static Win32BaseWindow *GetWindowFromOS2Handle(HWND hwnd);
196
197protected:
198 LRESULT SendInternalMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
199 LRESULT SendInternalMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
200 void Init();
201
202 char *getWindowNameA() { return windowNameA; };
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};
269
270
271#define BUTTON_LEFTDOWN 0
272#define BUTTON_LEFTUP 1
273#define BUTTON_LEFTDBLCLICK 2
274#define BUTTON_RIGHTUP 3
275#define BUTTON_RIGHTDOWN 4
276#define BUTTON_RIGHTDBLCLICK 5
277#define BUTTON_MIDDLEUP 6
278#define BUTTON_MIDDLEDOWN 7
279#define BUTTON_MIDDLEDBLCLICK 8
280
281#define WMMOVE_LBUTTON 1
282#define WMMOVE_MBUTTON 2
283#define WMMOVE_RBUTTON 4
284#define WMMOVE_CTRL 8
285#define WMMOVE_SHIFT 16
286
287
288#define CMD_MENU 1
289#define CMD_CONTROL 2
290#define CMD_ACCELERATOR 3
291
292#define WIN32SC_SIZE 0xf000
293#define WIN32SC_MOVE 0xf010
294#define WIN32SC_MINIMIZE 0xf020
295#define WIN32SC_MAXIMIZE 0xf030
296#define WIN32SC_NEXTWINDOW 0xf040
297#define WIN32SC_PREVWINDOW 0xf050
298#define WIN32SC_CLOSE 0xf060
299#define WIN32SC_VSCROLL 0xf070
300#define WIN32SC_HSCROLL 0xf080
301#define WIN32SC_MOUSEMENU 0xf090
302#define WIN32SC_KEYMENU 0xf100
303#define WIN32SC_ARRANGE 0xf110
304#define WIN32SC_RESTORE 0xf120
305#define WIN32SC_TASKLIST 0xf130
306#define WIN32SC_SCREENSAVE 0xf140
307#define WIN32SC_HOTKEY 0xf150
308
309#define KEY_ALTDOWN 1
310#define KEY_PREVDOWN 2
311#define KEY_UP 4
312#define KEY_DEADKEY 8
313
314#endif //__cplusplus
315
316#endif //__WIN32WNDBASE_H__
Note: See TracBrowser for help on using the repository browser.