1 | /* $Id: win32wnd.h,v 1.15 1999-07-19 18:40:44 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 |
|
---|
21 | class Win32Window;
|
---|
22 |
|
---|
23 | #define OFFSET_WIN32WNDPTR 0
|
---|
24 | #define OFFSET_WIN32PM_MAGIC 4
|
---|
25 |
|
---|
26 | #define WIN32PM_MAGIC 0x12345678
|
---|
27 | #define CheckMagicDword(a) (a==WIN32PM_MAGIC)
|
---|
28 |
|
---|
29 | typedef struct {
|
---|
30 | USHORT cb;
|
---|
31 | Win32Window *win32wnd;
|
---|
32 | ULONG win32CreateStruct; //or dialog create dword
|
---|
33 | } CUSTOMWNDDATA;
|
---|
34 |
|
---|
35 | typedef struct
|
---|
36 | {
|
---|
37 | ULONG Msg;
|
---|
38 | ULONG wParam;
|
---|
39 | ULONG lParam;
|
---|
40 | } POSTMSG_PACKET;
|
---|
41 |
|
---|
42 | #define WM_WIN32_POSTMESSAGEA 0x4000
|
---|
43 | #define WM_WIN32_POSTMESSAGEW 0x4001
|
---|
44 |
|
---|
45 | class Win32Window : private GenericObject, private ChildWindow
|
---|
46 | {
|
---|
47 | public:
|
---|
48 | DWORD magic;
|
---|
49 |
|
---|
50 | Win32Window(DWORD objType);
|
---|
51 | Win32Window(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode);
|
---|
52 | virtual ~Win32Window();
|
---|
53 |
|
---|
54 | virtual ULONG MsgCreate(HWND hwndOS2, ULONG initParam);
|
---|
55 | ULONG MsgQuit();
|
---|
56 | ULONG MsgClose();
|
---|
57 | ULONG MsgDestroy();
|
---|
58 | ULONG MsgEnable(BOOL fEnable);
|
---|
59 | ULONG MsgShow(BOOL fShow);
|
---|
60 | ULONG MsgMove(ULONG x, ULONG y);
|
---|
61 | ULONG MsgHitTest(ULONG x, ULONG y);
|
---|
62 | ULONG MsgSize(ULONG width, ULONG height, BOOL fMinimize, BOOL fMaximize);
|
---|
63 | ULONG MsgActivate(BOOL fActivate, HWND hwnd);
|
---|
64 | ULONG MsgSetFocus(HWND hwnd);
|
---|
65 | ULONG MsgKillFocus(HWND hwnd);
|
---|
66 | ULONG MsgCommand(ULONG cmd, ULONG Id, HWND hwnd);
|
---|
67 | ULONG MsgButton(ULONG msg, ULONG x, ULONG y);
|
---|
68 | ULONG MsgMouseMove(ULONG keystate, ULONG x, ULONG y);
|
---|
69 | ULONG MsgPaint(ULONG tmp1, ULONG tmp2);
|
---|
70 | ULONG MsgEraseBackGround(ULONG hps);
|
---|
71 | ULONG MsgSetText(LPSTR lpsz, LONG cch);
|
---|
72 |
|
---|
73 | virtual LONG SetWindowLongA(int index, ULONG value);
|
---|
74 | virtual ULONG GetWindowLongA(int index);
|
---|
75 | virtual WORD SetWindowWord(int index, WORD value);
|
---|
76 | virtual WORD GetWindowWord(int index);
|
---|
77 |
|
---|
78 | DWORD getStyle() { return dwStyle; };
|
---|
79 | DWORD getExStyle() { return dwExStyle; };
|
---|
80 | HWND getWindowHandle() { return Win32Hwnd; };
|
---|
81 | HWND getOS2WindowHandle() { return OS2Hwnd; };
|
---|
82 | Win32Window *getParent() { return (Win32Window *)ChildWindow::GetParent(); };
|
---|
83 | void setParent(Win32Window *pwindow) { ChildWindow::SetParent((ChildWindow *)pwindow); };
|
---|
84 | WNDPROC getWindowProc() { return win32wndproc; };
|
---|
85 | void setWindowProc(WNDPROC newproc) { win32wndproc = newproc; };
|
---|
86 | DWORD getWindowId() { return windowId; };
|
---|
87 | void setWindowId(DWORD id) { windowId = id; };
|
---|
88 | ULONG getWindowHeight() { return rectClient.bottom - rectClient.top; };
|
---|
89 |
|
---|
90 | DWORD getFlags() { return flags; };
|
---|
91 | void setFlags(DWORD newflags) { flags = newflags; };
|
---|
92 |
|
---|
93 | BOOL SetMenu(ULONG hMenu);
|
---|
94 | BOOL ShowWindow(ULONG nCmdShow);
|
---|
95 | BOOL SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags);
|
---|
96 | BOOL DestroyWindow();
|
---|
97 | HWND SetActiveWindow();
|
---|
98 | HWND GetParent();
|
---|
99 | HWND SetParent(HWND hwndNewParent);
|
---|
100 | BOOL IsChild(HWND hwndParent);
|
---|
101 | HWND GetTopWindow();
|
---|
102 | BOOL UpdateWindow();
|
---|
103 | BOOL IsIconic();
|
---|
104 | HWND GetWindow(UINT uCmd);
|
---|
105 | BOOL EnableWindow(BOOL fEnable);
|
---|
106 | BOOL CloseWindow();
|
---|
107 | BOOL BringWindowToTop();
|
---|
108 | static HWND GetActiveWindow();
|
---|
109 | BOOL IsWindow();
|
---|
110 | BOOL IsWindowEnabled();
|
---|
111 | BOOL IsWindowVisible();
|
---|
112 | BOOL IsUnicode() { return isUnicode; };
|
---|
113 |
|
---|
114 | BOOL GetWindowRect(PRECT pRect);
|
---|
115 | int GetWindowTextLengthA();
|
---|
116 | int GetWindowTextA(LPSTR lpsz, int cch);
|
---|
117 | BOOL SetWindowTextA(LPCSTR lpsz);
|
---|
118 |
|
---|
119 | LRESULT SendMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
|
---|
120 | LRESULT SendMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
|
---|
121 | BOOL PostMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
|
---|
122 | BOOL PostMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
|
---|
123 | LRESULT DefWindowProcA(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
---|
124 | LRESULT DefWindowProcW(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
---|
125 |
|
---|
126 | void NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam);
|
---|
127 |
|
---|
128 | Win32WndClass *getClass() { return windowClass; };
|
---|
129 |
|
---|
130 | static HWND Win32ToOS2Handle(HWND hwnd)
|
---|
131 | {
|
---|
132 | Win32Window *window = GetWindowFromHandle(hwnd);
|
---|
133 |
|
---|
134 | if(window) {
|
---|
135 | return window->getOS2WindowHandle();
|
---|
136 | }
|
---|
137 | else return hwnd; //OS/2 window handle
|
---|
138 | }
|
---|
139 |
|
---|
140 | static HWND OS2ToWin32Handle(HWND hwnd)
|
---|
141 | {
|
---|
142 | Win32Window *window = GetWindowFromOS2Handle(hwnd);
|
---|
143 |
|
---|
144 | if(window) {
|
---|
145 | return window->getWindowHandle();
|
---|
146 | }
|
---|
147 | else return hwnd; //OS/2 window handle
|
---|
148 | }
|
---|
149 |
|
---|
150 | static Win32Window *GetWindowFromHandle(HWND hwnd);
|
---|
151 | static Win32Window *GetWindowFromOS2Handle(HWND hwnd);
|
---|
152 |
|
---|
153 | protected:
|
---|
154 | LRESULT SendInternalMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
|
---|
155 | LRESULT SendInternalMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
|
---|
156 | void Init();
|
---|
157 |
|
---|
158 | HWND OS2Hwnd;
|
---|
159 | HWND OS2HwndFrame;
|
---|
160 | HWND OS2HwndMenu;
|
---|
161 | HWND Win32Hwnd;
|
---|
162 | BOOL isUnicode;
|
---|
163 |
|
---|
164 | int posx, posy, width, height;
|
---|
165 |
|
---|
166 | // values normally contained in the standard window words
|
---|
167 | ULONG dwExStyle; //GWL_EXSTYLE
|
---|
168 | ULONG dwStyle; //GWL_STYLE
|
---|
169 | WNDPROC win32wndproc; //GWL_WNDPROC
|
---|
170 | ULONG hInstance; //GWL_HINSTANCE
|
---|
171 | //Moved in ChildWindow class
|
---|
172 | ///// Win32Window *parent; //GWL_HWNDPARENT
|
---|
173 | ULONG windowId; //GWL_ID
|
---|
174 | ULONG userData; //GWL_USERDATA
|
---|
175 |
|
---|
176 | HWND hwndLinkAfter;
|
---|
177 | DWORD flags;
|
---|
178 | DWORD lastHitTestVal; //Last value returned by WM_NCHITTEST handler
|
---|
179 |
|
---|
180 | BOOL isIcon;
|
---|
181 |
|
---|
182 | Win32Window *owner;
|
---|
183 |
|
---|
184 | char *windowName;
|
---|
185 | ULONG wndNameLength;
|
---|
186 |
|
---|
187 | char *windowText;
|
---|
188 | ULONG wndTextLength;
|
---|
189 |
|
---|
190 | ULONG *userWindowLong;
|
---|
191 | ULONG nrUserWindowLong;
|
---|
192 |
|
---|
193 | RECT rectWindow;
|
---|
194 | RECT rectClient;
|
---|
195 |
|
---|
196 | Win32WndClass *windowClass;
|
---|
197 |
|
---|
198 | static GenericObject *windows;
|
---|
199 |
|
---|
200 | private:
|
---|
201 | #ifndef OS2_INCLUDED
|
---|
202 | BOOL CreateWindowExA(CREATESTRUCTA *lpCreateStruct, ATOM classAtom);
|
---|
203 |
|
---|
204 | void GetMinMaxInfo(POINT *maxSize, POINT *maxPos, POINT *minTrack, POINT *maxTrack );
|
---|
205 |
|
---|
206 | LONG SendNCCalcSize(BOOL calcValidRect,
|
---|
207 | RECT *newWindowRect, RECT *oldWindowRect,
|
---|
208 | RECT *oldClientRect, WINDOWPOS *winpos,
|
---|
209 | RECT *newClientRect );
|
---|
210 |
|
---|
211 | LRESULT SendInternalMessage(ULONG msg, WPARAM wParam, LPARAM lParam)
|
---|
212 | {
|
---|
213 | if(isUnicode)
|
---|
214 | return SendInternalMessageW(msg, wParam, lParam);
|
---|
215 | else return SendInternalMessageA(msg, wParam, lParam);
|
---|
216 | }
|
---|
217 | #endif
|
---|
218 | };
|
---|
219 |
|
---|
220 |
|
---|
221 | #define BUTTON_LEFTDOWN 0
|
---|
222 | #define BUTTON_LEFTUP 1
|
---|
223 | #define BUTTON_LEFTDBLCLICK 2
|
---|
224 | #define BUTTON_RIGHTUP 3
|
---|
225 | #define BUTTON_RIGHTDOWN 4
|
---|
226 | #define BUTTON_RIGHTDBLCLICK 5
|
---|
227 | #define BUTTON_MIDDLEUP 6
|
---|
228 | #define BUTTON_MIDDLEDOWN 7
|
---|
229 | #define BUTTON_MIDDLEDBLCLICK 8
|
---|
230 |
|
---|
231 | #define WMMOVE_LBUTTON 1
|
---|
232 | #define WMMOVE_MBUTTON 2
|
---|
233 | #define WMMOVE_RBUTTON 4
|
---|
234 | #define WMMOVE_CTRL 8
|
---|
235 | #define WMMOVE_SHIFT 16
|
---|
236 |
|
---|
237 |
|
---|
238 | #define CMD_MENU 1
|
---|
239 | #define CMD_CONTROL 2
|
---|
240 | #define CMD_ACCELERATOR 3
|
---|
241 |
|
---|
242 | #endif //__cplusplus
|
---|
243 |
|
---|
244 | #endif //__WIN32WND_H__
|
---|