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

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

More dialog update

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