1 | /* $Id: win32wnd.h,v 1.18 1999-07-25 09:19:22 sandervl Exp $ */
|
---|
2 | /*
|
---|
3 | * Win32 Window Code for OS/2
|
---|
4 | *
|
---|
5 | *
|
---|
6 | * Copyright 1998-1999 Sander van Leeuwen (sandervl@xs4all.nl)
|
---|
7 | *
|
---|
8 | *
|
---|
9 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
10 | *
|
---|
11 | */
|
---|
12 | #ifndef __WIN32WND_H__
|
---|
13 | #define __WIN32WND_H__
|
---|
14 |
|
---|
15 | #ifdef __cplusplus
|
---|
16 |
|
---|
17 | #include <win32class.h>
|
---|
18 | #include <gen_object.h>
|
---|
19 | #include <win32wndchild.h>
|
---|
20 | #include <winres.h>
|
---|
21 |
|
---|
22 | class Win32Window;
|
---|
23 |
|
---|
24 | #define OFFSET_WIN32WNDPTR 0
|
---|
25 | #define OFFSET_WIN32PM_MAGIC 4
|
---|
26 |
|
---|
27 | #define WIN32PM_MAGIC 0x12345678
|
---|
28 | #define CheckMagicDword(a) (a==WIN32PM_MAGIC)
|
---|
29 |
|
---|
30 | typedef struct {
|
---|
31 | USHORT cb;
|
---|
32 | Win32Window *win32wnd;
|
---|
33 | ULONG win32CreateStruct; //or dialog create dword
|
---|
34 | } CUSTOMWNDDATA;
|
---|
35 |
|
---|
36 | typedef struct
|
---|
37 | {
|
---|
38 | ULONG Msg;
|
---|
39 | ULONG wParam;
|
---|
40 | ULONG lParam;
|
---|
41 | } POSTMSG_PACKET;
|
---|
42 |
|
---|
43 | #define WM_WIN32_POSTMESSAGEA 0x4000
|
---|
44 | #define WM_WIN32_POSTMESSAGEW 0x4001
|
---|
45 |
|
---|
46 | class Win32Window : private GenericObject, private ChildWindow
|
---|
47 | {
|
---|
48 | public:
|
---|
49 | DWORD magic;
|
---|
50 |
|
---|
51 | Win32Window(DWORD objType);
|
---|
52 | Win32Window(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode);
|
---|
53 | virtual ~Win32Window();
|
---|
54 |
|
---|
55 | virtual ULONG MsgCreate(HWND hwndOS2, ULONG initParam);
|
---|
56 | ULONG MsgQuit();
|
---|
57 | ULONG MsgClose();
|
---|
58 | ULONG MsgDestroy();
|
---|
59 | ULONG MsgEnable(BOOL fEnable);
|
---|
60 | ULONG MsgShow(BOOL fShow);
|
---|
61 | ULONG MsgMove(ULONG x, ULONG y);
|
---|
62 | ULONG MsgHitTest(ULONG x, ULONG y);
|
---|
63 | ULONG MsgSize(ULONG width, ULONG height, BOOL fMinimize, BOOL fMaximize);
|
---|
64 | ULONG MsgActivate(BOOL fActivate, HWND hwnd);
|
---|
65 | ULONG MsgSetFocus(HWND hwnd);
|
---|
66 | ULONG MsgKillFocus(HWND hwnd);
|
---|
67 | ULONG MsgCommand(ULONG cmd, ULONG Id, HWND hwnd);
|
---|
68 | ULONG MsgSysCommand(ULONG win32sc, ULONG x, ULONG y);
|
---|
69 | ULONG MsgChar(ULONG cmd, ULONG repeatcnt, ULONG scancode, ULONG vkey, ULONG keyflags);
|
---|
70 | ULONG MsgButton(ULONG msg, ULONG x, ULONG y);
|
---|
71 | ULONG MsgMouseMove(ULONG keystate, ULONG x, ULONG y);
|
---|
72 | ULONG MsgPaint(ULONG tmp1, ULONG tmp2);
|
---|
73 | ULONG MsgEraseBackGround(ULONG hps);
|
---|
74 | ULONG MsgSetText(LPSTR lpsz, LONG cch);
|
---|
75 |
|
---|
76 | virtual LONG SetWindowLongA(int index, ULONG value);
|
---|
77 | virtual ULONG GetWindowLongA(int index);
|
---|
78 | virtual WORD SetWindowWord(int index, WORD value);
|
---|
79 | virtual WORD GetWindowWord(int index);
|
---|
80 |
|
---|
81 | DWORD getStyle() { return dwStyle; };
|
---|
82 | DWORD getExStyle() { return dwExStyle; };
|
---|
83 | HWND getWindowHandle() { return Win32Hwnd; };
|
---|
84 | HWND getOS2WindowHandle() { return OS2Hwnd; };
|
---|
85 | HWND getOS2FrameWindowHandle() { return OS2HwndFrame; };
|
---|
86 | Win32Window *getParent() { return (Win32Window *)ChildWindow::GetParent(); };
|
---|
87 | void setParent(Win32Window *pwindow) { ChildWindow::SetParent((ChildWindow *)pwindow); };
|
---|
88 | WNDPROC getWindowProc() { return win32wndproc; };
|
---|
89 | void setWindowProc(WNDPROC newproc) { win32wndproc = newproc; };
|
---|
90 | DWORD getWindowId() { return windowId; };
|
---|
91 | void setWindowId(DWORD id) { windowId = id; };
|
---|
92 | ULONG getWindowHeight() { return rectClient.bottom - rectClient.top; };
|
---|
93 | BOOL isChild();
|
---|
94 |
|
---|
95 | DWORD getFlags() { return flags; };
|
---|
96 | void setFlags(DWORD newflags) { flags = newflags; };
|
---|
97 |
|
---|
98 | HACCEL GetAccelTable() { return (HACCEL) acceltableResource; };
|
---|
99 | BOOL SetAccelTable(ULONG hAccel);
|
---|
100 |
|
---|
101 | HMENU GetMenu() { return (HMENU) menuResource; };
|
---|
102 | BOOL SetMenu(ULONG hMenu);
|
---|
103 |
|
---|
104 | BOOL SetIcon(HICON hIcon);
|
---|
105 | HICON GetIcon() { return (HICON) iconResource; };
|
---|
106 |
|
---|
107 | BOOL ShowWindow(ULONG nCmdShow);
|
---|
108 | BOOL SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags);
|
---|
109 | BOOL DestroyWindow();
|
---|
110 | HWND SetActiveWindow();
|
---|
111 | HWND GetParent();
|
---|
112 | HWND SetParent(HWND hwndNewParent);
|
---|
113 | BOOL IsChild(HWND hwndParent);
|
---|
114 | HWND GetTopWindow();
|
---|
115 | BOOL UpdateWindow();
|
---|
116 | BOOL IsIconic();
|
---|
117 | HWND GetWindow(UINT uCmd);
|
---|
118 | BOOL EnableWindow(BOOL fEnable);
|
---|
119 | BOOL CloseWindow();
|
---|
120 | BOOL BringWindowToTop();
|
---|
121 | static HWND GetActiveWindow();
|
---|
122 | BOOL IsWindow();
|
---|
123 | BOOL IsWindowEnabled();
|
---|
124 | BOOL IsWindowVisible();
|
---|
125 | BOOL IsUnicode() { return isUnicode; };
|
---|
126 |
|
---|
127 | BOOL GetWindowRect(PRECT pRect);
|
---|
128 | int GetWindowTextLengthA();
|
---|
129 | int GetWindowTextA(LPSTR lpsz, int cch);
|
---|
130 | BOOL SetWindowTextA(LPCSTR lpsz);
|
---|
131 |
|
---|
132 | LRESULT SendMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
|
---|
133 | LRESULT SendMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
|
---|
134 | BOOL PostMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
|
---|
135 | BOOL PostMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
|
---|
136 | LRESULT DefWindowProcA(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
---|
137 | LRESULT DefWindowProcW(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
---|
138 |
|
---|
139 | void NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam);
|
---|
140 |
|
---|
141 | Win32WndClass *getClass() { return windowClass; };
|
---|
142 |
|
---|
143 | static HWND Win32ToOS2Handle(HWND hwnd)
|
---|
144 | {
|
---|
145 | Win32Window *window = GetWindowFromHandle(hwnd);
|
---|
146 |
|
---|
147 | if(window) {
|
---|
148 | return window->getOS2WindowHandle();
|
---|
149 | }
|
---|
150 | else return hwnd; //OS/2 window handle
|
---|
151 | }
|
---|
152 |
|
---|
153 | static HWND OS2ToWin32Handle(HWND hwnd)
|
---|
154 | {
|
---|
155 | Win32Window *window = GetWindowFromOS2Handle(hwnd);
|
---|
156 |
|
---|
157 | if(window) {
|
---|
158 | return window->getWindowHandle();
|
---|
159 | }
|
---|
160 | else return hwnd; //OS/2 window handle
|
---|
161 | }
|
---|
162 |
|
---|
163 | static Win32Window *GetWindowFromHandle(HWND hwnd);
|
---|
164 | static Win32Window *GetWindowFromOS2Handle(HWND hwnd);
|
---|
165 |
|
---|
166 | protected:
|
---|
167 | LRESULT SendInternalMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
|
---|
168 | LRESULT SendInternalMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
|
---|
169 | void Init();
|
---|
170 |
|
---|
171 | HWND OS2Hwnd;
|
---|
172 | HWND OS2HwndFrame;
|
---|
173 | HWND OS2HwndMenu;
|
---|
174 | HWND Win32Hwnd;
|
---|
175 | BOOL isUnicode;
|
---|
176 |
|
---|
177 | int posx, posy, width, height;
|
---|
178 |
|
---|
179 | // values normally contained in the standard window words
|
---|
180 | ULONG dwExStyle; //GWL_EXSTYLE
|
---|
181 | ULONG dwStyle; //GWL_STYLE
|
---|
182 | WNDPROC win32wndproc; //GWL_WNDPROC
|
---|
183 | ULONG hInstance; //GWL_HINSTANCE
|
---|
184 | //Moved in ChildWindow class
|
---|
185 | ///// Win32Window *parent; //GWL_HWNDPARENT
|
---|
186 | ULONG windowId; //GWL_ID
|
---|
187 | ULONG userData; //GWL_USERDATA
|
---|
188 |
|
---|
189 | HWND hwndLinkAfter;
|
---|
190 | DWORD flags;
|
---|
191 | DWORD lastHitTestVal; //Last value returned by WM_NCHITTEST handler
|
---|
192 |
|
---|
193 | BOOL isIcon;
|
---|
194 |
|
---|
195 | Win32Window *owner;
|
---|
196 |
|
---|
197 | Win32Resource *acceltableResource;
|
---|
198 | Win32Resource *menuResource;
|
---|
199 | Win32Resource *iconResource;
|
---|
200 |
|
---|
201 | char *windowName;
|
---|
202 | ULONG wndNameLength;
|
---|
203 |
|
---|
204 | char *windowText;
|
---|
205 | ULONG wndTextLength;
|
---|
206 |
|
---|
207 | ULONG *userWindowLong;
|
---|
208 | ULONG nrUserWindowLong;
|
---|
209 |
|
---|
210 | RECT rectWindow;
|
---|
211 | RECT rectClient;
|
---|
212 |
|
---|
213 | Win32WndClass *windowClass;
|
---|
214 |
|
---|
215 | static GenericObject *windows;
|
---|
216 |
|
---|
217 | private:
|
---|
218 | #ifndef OS2_INCLUDED
|
---|
219 | BOOL CreateWindowExA(CREATESTRUCTA *lpCreateStruct, ATOM classAtom);
|
---|
220 |
|
---|
221 | void GetMinMaxInfo(POINT *maxSize, POINT *maxPos, POINT *minTrack, POINT *maxTrack );
|
---|
222 |
|
---|
223 | LONG SendNCCalcSize(BOOL calcValidRect,
|
---|
224 | RECT *newWindowRect, RECT *oldWindowRect,
|
---|
225 | RECT *oldClientRect, WINDOWPOS *winpos,
|
---|
226 | RECT *newClientRect );
|
---|
227 |
|
---|
228 | LRESULT SendInternalMessage(ULONG msg, WPARAM wParam, LPARAM lParam)
|
---|
229 | {
|
---|
230 | if(isUnicode)
|
---|
231 | return SendInternalMessageW(msg, wParam, lParam);
|
---|
232 | else return SendInternalMessageA(msg, wParam, lParam);
|
---|
233 | }
|
---|
234 | #endif
|
---|
235 | };
|
---|
236 |
|
---|
237 |
|
---|
238 | #define BUTTON_LEFTDOWN 0
|
---|
239 | #define BUTTON_LEFTUP 1
|
---|
240 | #define BUTTON_LEFTDBLCLICK 2
|
---|
241 | #define BUTTON_RIGHTUP 3
|
---|
242 | #define BUTTON_RIGHTDOWN 4
|
---|
243 | #define BUTTON_RIGHTDBLCLICK 5
|
---|
244 | #define BUTTON_MIDDLEUP 6
|
---|
245 | #define BUTTON_MIDDLEDOWN 7
|
---|
246 | #define BUTTON_MIDDLEDBLCLICK 8
|
---|
247 |
|
---|
248 | #define WMMOVE_LBUTTON 1
|
---|
249 | #define WMMOVE_MBUTTON 2
|
---|
250 | #define WMMOVE_RBUTTON 4
|
---|
251 | #define WMMOVE_CTRL 8
|
---|
252 | #define WMMOVE_SHIFT 16
|
---|
253 |
|
---|
254 |
|
---|
255 | #define CMD_MENU 1
|
---|
256 | #define CMD_CONTROL 2
|
---|
257 | #define CMD_ACCELERATOR 3
|
---|
258 |
|
---|
259 | #define WIN32SC_SIZE 0xf000
|
---|
260 | #define WIN32SC_MOVE 0xf010
|
---|
261 | #define WIN32SC_MINIMIZE 0xf020
|
---|
262 | #define WIN32SC_MAXIMIZE 0xf030
|
---|
263 | #define WIN32SC_NEXTWINDOW 0xf040
|
---|
264 | #define WIN32SC_PREVWINDOW 0xf050
|
---|
265 | #define WIN32SC_CLOSE 0xf060
|
---|
266 | #define WIN32SC_VSCROLL 0xf070
|
---|
267 | #define WIN32SC_HSCROLL 0xf080
|
---|
268 | #define WIN32SC_MOUSEMENU 0xf090
|
---|
269 | #define WIN32SC_KEYMENU 0xf100
|
---|
270 | #define WIN32SC_ARRANGE 0xf110
|
---|
271 | #define WIN32SC_RESTORE 0xf120
|
---|
272 | #define WIN32SC_TASKLIST 0xf130
|
---|
273 | #define WIN32SC_SCREENSAVE 0xf140
|
---|
274 | #define WIN32SC_HOTKEY 0xf150
|
---|
275 |
|
---|
276 | #define KEY_ALTDOWN 1
|
---|
277 | #define KEY_PREVDOWN 2
|
---|
278 | #define KEY_UP 4
|
---|
279 |
|
---|
280 | #endif //__cplusplus
|
---|
281 |
|
---|
282 | #endif //__WIN32WND_H__
|
---|