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

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

Redesign; base class for all window types

File size: 10.6 KB
Line 
1/* $Id: win32wbase.h,v 1.1 1999-08-30 12:00:12 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, private 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 DWORD getExStyle() { return dwExStyle; };
92 HWND getWindowHandle() { return Win32Hwnd; };
93 HWND getOS2WindowHandle() { return OS2Hwnd; };
94 HWND getOS2FrameWindowHandle() { return OS2HwndFrame; };
95 Win32WndClass *getWindowClass() { return windowClass; };
96
97 BOOL isFrameWindow() { return OS2Hwnd != OS2HwndFrame; };
98Win32BaseWindow *getParent() { return (Win32BaseWindow *)ChildWindow::GetParent(); };
99 void setParent(Win32BaseWindow *pwindow) { ChildWindow::SetParent((ChildWindow *)pwindow); };
100 WNDPROC getWindowProc() { return win32wndproc; };
101 void setWindowProc(WNDPROC newproc) { win32wndproc = newproc; };
102 DWORD getWindowId() { return windowId; };
103 void setWindowId(DWORD id) { windowId = id; };
104 ULONG getWindowHeight() { return rectClient.bottom - rectClient.top; };
105 BOOL isChild();
106 PRECT getClientRect() { return &rectClient; };
107 PRECT getWindowRect() { return &rectWindow; };
108 void setClientRect(LONG left, LONG top, LONG right, LONG bottom)
109 {
110 rectClient.left = left; rectClient.top = top;
111 rectClient.right = right; rectClient.bottom = bottom;
112 };
113 void setWindowRect(LONG left, LONG top, LONG right, LONG bottom)
114 {
115 rectWindow.left = left; rectWindow.top = top;
116 rectWindow.right = right; rectWindow.bottom = bottom;
117 };
118 void setWindowRect(PRECT rect) { rectWindow = *rect; };
119
120 DWORD getFlags() { return flags; };
121 void setFlags(DWORD newflags) { flags = newflags; };
122
123 HACCEL GetAccelTable() { return (HACCEL) acceltableResource; };
124 BOOL SetAccelTable(ULONG hAccel);
125
126 HMENU GetMenu() { return (HMENU) menuResource; };
127 BOOL SetMenu(ULONG hMenu);
128
129 BOOL SetIcon(HICON hIcon);
130 HICON GetIcon() { return (HICON) iconResource; };
131
132 BOOL ShowWindow(ULONG nCmdShow);
133 BOOL SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags);
134 BOOL DestroyWindow();
135 HWND SetActiveWindow();
136 HWND GetParent();
137 HWND SetParent(HWND hwndNewParent);
138 BOOL IsChild(HWND hwndParent);
139 HWND GetTopWindow();
140 BOOL UpdateWindow();
141 BOOL IsIconic();
142 HWND GetWindow(UINT uCmd);
143 BOOL EnableWindow(BOOL fEnable);
144 BOOL CloseWindow();
145 static HWND GetActiveWindow();
146 BOOL IsWindow();
147 BOOL IsWindowEnabled();
148 BOOL IsWindowVisible();
149 BOOL IsUnicode() { return isUnicode; };
150
151 BOOL GetWindowRect(PRECT pRect);
152 int GetWindowTextLengthA();
153 int GetWindowTextA(LPSTR lpsz, int cch);
154 BOOL SetWindowText(LPSTR lpsz);
155 BOOL hasWindowName(LPSTR wndname, BOOL fUnicode = 0);
156
157 LRESULT SendMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
158 LRESULT SendMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
159 BOOL PostMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
160 BOOL PostMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
161 LRESULT DefWindowProcA(UINT msg, WPARAM wParam, LPARAM lParam);
162 LRESULT DefWindowProcW(UINT msg, WPARAM wParam, LPARAM lParam);
163
164 void NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam);
165
166Win32WndClass *getClass() { return windowClass; };
167
168 static HWND FindWindowEx(HWND hwndParent, HWND hwndChildAfter, LPSTR lpszClass, LPSTR lpszWindow,
169 BOOL fUnicode = 0);
170
171 static HWND Win32ToOS2Handle(HWND hwnd)
172 {
173 Win32BaseWindow *window = GetWindowFromHandle(hwnd);
174
175 if(window) {
176 return window->getOS2WindowHandle();
177 }
178 else return hwnd; //OS/2 window handle
179 }
180
181 static HWND OS2ToWin32Handle(HWND hwnd)
182 {
183 Win32BaseWindow *window = GetWindowFromOS2Handle(hwnd);
184
185 if(window) {
186 return window->getWindowHandle();
187 }
188 else return hwnd; //OS/2 window handle
189 }
190
191static Win32BaseWindow *GetWindowFromHandle(HWND hwnd);
192static Win32BaseWindow *GetWindowFromOS2Handle(HWND hwnd);
193
194protected:
195 LRESULT SendInternalMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
196 LRESULT SendInternalMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
197 void Init();
198
199 HWND OS2Hwnd;
200 HWND OS2HwndFrame;
201 HWND OS2HwndMenu;
202 HWND Win32Hwnd;
203 BOOL isUnicode;
204
205 int posx, posy, width, height;
206
207 // values normally contained in the standard window words
208 ULONG dwExStyle; //GWL_EXSTYLE
209 ULONG dwStyle; //GWL_STYLE
210 WNDPROC win32wndproc; //GWL_WNDPROC
211 ULONG hInstance; //GWL_HINSTANCE
212//Moved in ChildWindow class
213///// Win32BaseWindow *parent; //GWL_HWNDPARENT
214 ULONG windowId; //GWL_ID
215 ULONG userData; //GWL_USERDATA
216
217 HWND hwndLinkAfter;
218 DWORD flags;
219 DWORD lastHitTestVal; //Last value returned by WM_NCHITTEST handler
220
221 BOOL isIcon;
222 BOOL fCreated;
223 BOOL fFirstShow;
224
225 Win32BaseWindow *owner;
226
227 Win32Resource *acceltableResource;
228 Win32Resource *menuResource;
229 Win32Resource *iconResource;
230
231 char *windowNameA;
232 WCHAR *windowNameW;
233 ULONG wndNameLength; //including 0 terminator
234
235 ULONG *userWindowLong;
236 ULONG nrUserWindowLong;
237
238 RECT rectWindow;
239 RECT rectClient;
240
241Win32WndClass *windowClass;
242
243static GenericObject *windows;
244
245private:
246#ifndef OS2_INCLUDED
247 BOOL CreateWindowExA(CREATESTRUCTA *lpCreateStruct, ATOM classAtom);
248
249 void GetMinMaxInfo(POINT *maxSize, POINT *maxPos, POINT *minTrack, POINT *maxTrack );
250
251 LONG SendNCCalcSize(BOOL calcValidRect,
252 RECT *newWindowRect, RECT *oldWindowRect,
253 RECT *oldClientRect, WINDOWPOS *winpos,
254 RECT *newClientRect );
255
256 LRESULT SendInternalMessage(ULONG msg, WPARAM wParam, LPARAM lParam)
257 {
258 if(isUnicode)
259 return SendInternalMessageW(msg, wParam, lParam);
260 else return SendInternalMessageA(msg, wParam, lParam);
261 }
262#endif
263};
264
265
266#define BUTTON_LEFTDOWN 0
267#define BUTTON_LEFTUP 1
268#define BUTTON_LEFTDBLCLICK 2
269#define BUTTON_RIGHTUP 3
270#define BUTTON_RIGHTDOWN 4
271#define BUTTON_RIGHTDBLCLICK 5
272#define BUTTON_MIDDLEUP 6
273#define BUTTON_MIDDLEDOWN 7
274#define BUTTON_MIDDLEDBLCLICK 8
275
276#define WMMOVE_LBUTTON 1
277#define WMMOVE_MBUTTON 2
278#define WMMOVE_RBUTTON 4
279#define WMMOVE_CTRL 8
280#define WMMOVE_SHIFT 16
281
282
283#define CMD_MENU 1
284#define CMD_CONTROL 2
285#define CMD_ACCELERATOR 3
286
287#define WIN32SC_SIZE 0xf000
288#define WIN32SC_MOVE 0xf010
289#define WIN32SC_MINIMIZE 0xf020
290#define WIN32SC_MAXIMIZE 0xf030
291#define WIN32SC_NEXTWINDOW 0xf040
292#define WIN32SC_PREVWINDOW 0xf050
293#define WIN32SC_CLOSE 0xf060
294#define WIN32SC_VSCROLL 0xf070
295#define WIN32SC_HSCROLL 0xf080
296#define WIN32SC_MOUSEMENU 0xf090
297#define WIN32SC_KEYMENU 0xf100
298#define WIN32SC_ARRANGE 0xf110
299#define WIN32SC_RESTORE 0xf120
300#define WIN32SC_TASKLIST 0xf130
301#define WIN32SC_SCREENSAVE 0xf140
302#define WIN32SC_HOTKEY 0xf150
303
304#define KEY_ALTDOWN 1
305#define KEY_PREVDOWN 2
306#define KEY_UP 4
307#define KEY_DEADKEY 8
308
309#endif //__cplusplus
310
311#endif //__WIN32WNDBASE_H__
Note: See TracBrowser for help on using the repository browser.