source: trunk/src/user32/new/win32wnd.h@ 729

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

Window handle changes (now allocated in shared array) + postmessage changes + fixes

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