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

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

Dialog changes

File size: 11.5 KB
Line 
1/* $Id: win32wbase.h,v 1.5 1999-09-04 19:42:29 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
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 //Window handle has already been verified, so just return true
151 BOOL IsWindow() { return TRUE; };
152 BOOL IsWindowEnabled();
153 BOOL IsWindowVisible();
154 BOOL IsUnicode() { return isUnicode; };
155
156 BOOL GetWindowRect(PRECT pRect);
157 int GetWindowTextLength();
158 int GetWindowText(LPSTR lpsz, int cch);
159 BOOL SetWindowText(LPSTR lpsz);
160 BOOL hasWindowName(LPSTR wndname, BOOL fUnicode = 0);
161Win32WndClass *getClass() { return windowClass; };
162 char *getWindowNameA() { return windowNameA; };
163Win32BaseWindow *getOwner() { return owner; };
164
165 LRESULT SendMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
166 LRESULT SendMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
167 BOOL PostMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
168 BOOL PostMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
169 LRESULT DefWindowProcA(UINT msg, WPARAM wParam, LPARAM lParam);
170 LRESULT DefWindowProcW(UINT msg, WPARAM wParam, LPARAM lParam);
171
172 void NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam);
173
174 static HWND FindWindowEx(HWND hwndParent, HWND hwndChildAfter, LPSTR lpszClass, LPSTR lpszWindow,
175 BOOL fUnicode = 0);
176
177 static HWND Win32ToOS2Handle(HWND hwnd)
178 {
179 Win32BaseWindow *window = GetWindowFromHandle(hwnd);
180
181 if(window) {
182 return window->getOS2WindowHandle();
183 }
184 else return hwnd; //OS/2 window handle
185 }
186
187 static HWND OS2ToWin32Handle(HWND hwnd)
188 {
189 Win32BaseWindow *window = GetWindowFromOS2Handle(hwnd);
190
191 if(window) {
192 return window->getWindowHandle();
193 }
194 else return hwnd; //OS/2 window handle
195 }
196
197static Win32BaseWindow *GetWindowFromHandle(HWND hwnd);
198static Win32BaseWindow *GetWindowFromOS2Handle(HWND hwnd);
199
200protected:
201#ifndef OS2_INCLUDED
202 BOOL CreateWindowExA(CREATESTRUCTA *lpCreateStruct, ATOM classAtom);
203#endif
204 LRESULT SendInternalMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
205 LRESULT SendInternalMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
206 void Init();
207
208 HWND OS2Hwnd;
209 HWND OS2HwndFrame;
210 HWND OS2HwndMenu;
211 HWND Win32Hwnd;
212 BOOL isUnicode;
213
214 int posx, posy, width, height;
215
216 // values normally contained in the standard window words
217 ULONG dwExStyle; //GWL_EXSTYLE
218 ULONG dwStyle; //GWL_STYLE
219 WNDPROC win32wndproc; //GWL_WNDPROC
220 ULONG hInstance; //GWL_HINSTANCE
221//Moved in ChildWindow class
222///// Win32BaseWindow *parent; //GWL_HWNDPARENT
223 ULONG windowId; //GWL_ID
224 ULONG userData; //GWL_USERDATA
225
226 HWND hwndLinkAfter;
227 DWORD flags;
228 DWORD lastHitTestVal; //Last value returned by WM_NCHITTEST handler
229
230 BOOL isIcon;
231 BOOL fCreated;
232 BOOL fFirstShow;
233 BOOL fIsDialog;
234
235 Win32BaseWindow *owner;
236
237 Win32Resource *acceltableResource;
238 Win32Resource *menuResource;
239 Win32Resource *iconResource;
240
241 char *windowNameA;
242 WCHAR *windowNameW;
243 ULONG wndNameLength; //including 0 terminator
244
245 ULONG *userWindowLong;
246 ULONG nrUserWindowLong;
247
248 RECT rectWindow;
249 RECT rectClient;
250
251Win32WndClass *windowClass;
252
253static GenericObject *windows;
254
255private:
256#ifndef OS2_INCLUDED
257 void GetMinMaxInfo(POINT *maxSize, POINT *maxPos, POINT *minTrack, POINT *maxTrack );
258
259 LONG SendNCCalcSize(BOOL calcValidRect,
260 RECT *newWindowRect, RECT *oldWindowRect,
261 RECT *oldClientRect, WINDOWPOS *winpos,
262 RECT *newClientRect );
263
264 LRESULT SendInternalMessage(ULONG msg, WPARAM wParam, LPARAM lParam)
265 {
266 if(isUnicode)
267 return SendInternalMessageW(msg, wParam, lParam);
268 else return SendInternalMessageA(msg, wParam, lParam);
269 }
270#endif
271
272public:
273 void SetFakeOpen32() { WinSetDAXData (OS2Hwnd, &fakeWinBase); }
274 void RemoveFakeOpen32() { WinSetDAXData (OS2Hwnd, NULL); }
275
276 fakeOpen32WinBaseClass fakeWinBase;
277};
278
279
280#define BUTTON_LEFTDOWN 0
281#define BUTTON_LEFTUP 1
282#define BUTTON_LEFTDBLCLICK 2
283#define BUTTON_RIGHTUP 3
284#define BUTTON_RIGHTDOWN 4
285#define BUTTON_RIGHTDBLCLICK 5
286#define BUTTON_MIDDLEUP 6
287#define BUTTON_MIDDLEDOWN 7
288#define BUTTON_MIDDLEDBLCLICK 8
289
290#define WMMOVE_LBUTTON 1
291#define WMMOVE_MBUTTON 2
292#define WMMOVE_RBUTTON 4
293#define WMMOVE_CTRL 8
294#define WMMOVE_SHIFT 16
295
296
297#define CMD_MENU 1
298#define CMD_CONTROL 2
299#define CMD_ACCELERATOR 3
300
301#define WIN32SC_SIZE 0xf000
302#define WIN32SC_MOVE 0xf010
303#define WIN32SC_MINIMIZE 0xf020
304#define WIN32SC_MAXIMIZE 0xf030
305#define WIN32SC_NEXTWINDOW 0xf040
306#define WIN32SC_PREVWINDOW 0xf050
307#define WIN32SC_CLOSE 0xf060
308#define WIN32SC_VSCROLL 0xf070
309#define WIN32SC_HSCROLL 0xf080
310#define WIN32SC_MOUSEMENU 0xf090
311#define WIN32SC_KEYMENU 0xf100
312#define WIN32SC_ARRANGE 0xf110
313#define WIN32SC_RESTORE 0xf120
314#define WIN32SC_TASKLIST 0xf130
315#define WIN32SC_SCREENSAVE 0xf140
316#define WIN32SC_HOTKEY 0xf150
317
318#define KEY_ALTDOWN 1
319#define KEY_PREVDOWN 2
320#define KEY_UP 4
321#define KEY_DEADKEY 8
322
323#endif //__cplusplus
324
325#endif //__WIN32WNDBASE_H__
Note: See TracBrowser for help on using the repository browser.