source: trunk/src/user32/win32wbase.h@ 1036

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

Menu changes

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