1 | /* $Id: pmwindow.cpp,v 1.38 1999-10-20 22:35:53 sandervl Exp $ */
|
---|
2 | /*
|
---|
3 | * Win32 Window Managment Code for OS/2
|
---|
4 | *
|
---|
5 | * Copyright 1998-1999 Sander van Leeuwen (sandervl@xs4all.nl)
|
---|
6 | * Copyright 1999 Daniela Engert (dani@ngrt.de)
|
---|
7 | *
|
---|
8 | *
|
---|
9 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
10 | *
|
---|
11 | */
|
---|
12 | #define INCL_WIN
|
---|
13 | #define INCL_GPI
|
---|
14 |
|
---|
15 | #include <os2.h> /* PM header file */
|
---|
16 | #include <os2wrap.h>
|
---|
17 | #include <stdlib.h>
|
---|
18 | #include "win32type.h"
|
---|
19 | #include <winconst.h>
|
---|
20 | #include <wprocess.h>
|
---|
21 | #include <misc.h>
|
---|
22 | #include <win32wbase.h>
|
---|
23 | #include <win32dlg.h>
|
---|
24 | #include "win32wdesktop.h"
|
---|
25 | #include "pmwindow.h"
|
---|
26 | #include "oslibwin.h"
|
---|
27 | #include "oslibutil.h"
|
---|
28 | #include "oslibgdi.h"
|
---|
29 | #include "oslibmsg.h"
|
---|
30 | #include "dc.h"
|
---|
31 | #include <thread.h>
|
---|
32 | #include <wprocess.h>
|
---|
33 | #include <caret.h>
|
---|
34 |
|
---|
35 | HMQ hmq = 0; /* Message queue handle */
|
---|
36 | HAB hab = 0;
|
---|
37 |
|
---|
38 | RECTL desktopRectl = {0};
|
---|
39 | ULONG ScreenWidth = 0;
|
---|
40 | ULONG ScreenHeight = 0;
|
---|
41 |
|
---|
42 | //Used for key translation while processing WM_CHAR message
|
---|
43 | USHORT virtualKeyTable [66] = {
|
---|
44 | 0x00, // OS/2 VK Win32 VK, Entry 0 is not used
|
---|
45 | 0x01, // VK_BUTTON1 VK_LBUTTON
|
---|
46 | 0x02, // VK_BUTTON2 VK_RBUTTON
|
---|
47 | 0x04, // VK_BUTTON3 VK_MBUTTON
|
---|
48 | 0x03, // VK_BREAK VK_CANCEL
|
---|
49 | 0x08, // VK_BACKSPACE VK_BACK
|
---|
50 | 0x09, // VK_TAB VK_TAB
|
---|
51 | 0x00, // VK_BACKTAB No equivalent!
|
---|
52 | 0x0D, // VK_NEWLINE VK_RETURN
|
---|
53 | 0x10, // VK_SHIFT VK_SHIFT
|
---|
54 | 0x11, // VK_CTRL VK_CONTROL
|
---|
55 | 0x12, // VK_ALT VK_MENU, best match I guess
|
---|
56 | 0x12, // VK_ALTGRAF VK_MENU, best match I guess
|
---|
57 | 0x13, // VK_PAUSE VK_PAUSE
|
---|
58 | 0x14, // VK_CAPSLOCK VK_CAPITAL
|
---|
59 | 0x1B, // VK_ESC VK_ESCAPE
|
---|
60 | 0x20, // VK_SPACE VK_SPACE
|
---|
61 | 0x21, // VK_PAGEUP VK_PRIOR
|
---|
62 | 0x22, // VK_PAGEDOWN VK_NEXT
|
---|
63 | 0x23, // VK_END VK_END
|
---|
64 | 0x24, // VK_HOME VK_HOME
|
---|
65 | 0x25, // VK_LEFT VK_LEFT
|
---|
66 | 0x26, // VK_UP VK_UP
|
---|
67 | 0x27, // VK_RIGHT VK_RIGHT
|
---|
68 | 0x28, // VK_DOWN VK_DOWN
|
---|
69 | 0x2C, // VK_PRINTSCRN VK_SNAPSHOT
|
---|
70 | 0x2D, // VK_INSERT VK_INSERT
|
---|
71 | 0x2E, // VK_DELETE VK_DELETE
|
---|
72 | 0x91, // VK_SCRLLOCK VK_SCROLL
|
---|
73 | 0x90, // VK_NUMLOCK VK_NUMLOCK
|
---|
74 | 0x2B, // VK_ENTER VK_EXECUTE, best match I guess
|
---|
75 | 0x00, // VK_SYSRQ No equivalent!
|
---|
76 | 0x70, // VK_F1 VK_F1
|
---|
77 | 0x71, // VK_F2 VK_F2
|
---|
78 | 0x72, // VK_F3 VK_F3
|
---|
79 | 0x73, // VK_F4 VK_F4
|
---|
80 | 0x74, // VK_F5 VK_F5
|
---|
81 | 0x75, // VK_F6 VK_F6
|
---|
82 | 0x76, // VK_F7 VK_F7
|
---|
83 | 0x77, // VK_F8 VK_F8
|
---|
84 | 0x78, // VK_F9 VK_F9
|
---|
85 | 0x79, // VK_F10 VK_F10
|
---|
86 | 0x7A, // VK_F11 VK_F11
|
---|
87 | 0x7B, // VK_F12 VK_F12
|
---|
88 | 0x7C, // VK_F13 VK_F13
|
---|
89 | 0x7D, // VK_F14 VK_F14
|
---|
90 | 0x7E, // VK_F15 VK_F15
|
---|
91 | 0x7F, // VK_F16 VK_F16
|
---|
92 | 0x80, // VK_F17 VK_F17
|
---|
93 | 0x81, // VK_F18 VK_F18
|
---|
94 | 0x82, // VK_F19 VK_F19
|
---|
95 | 0x83, // VK_F20 VK_F20
|
---|
96 | 0x84, // VK_F21 VK_F21
|
---|
97 | 0x85, // VK_F22 VK_F22
|
---|
98 | 0x86, // VK_F23 VK_F23
|
---|
99 | 0x87, // VK_F24 VK_F24
|
---|
100 | 0x00, // VK_ENDDRAG No equivalent!
|
---|
101 | 0x0C, // VK_CLEAR VK_CLEAR
|
---|
102 | 0xF9, // VK_EREOF VK_EREOF
|
---|
103 | 0xFD, // VK_PA1 VK_PA1
|
---|
104 | 0xF6, // VK_ATTN VK_ATTN
|
---|
105 | 0xF7, // VK_CRSEL VK_CRSEL
|
---|
106 | 0xF8, // VK_EXSEL VK_EXSEL
|
---|
107 | 0x00, // VK_COPY No equivalent!
|
---|
108 | 0x00, // VK_BLK1 No equivalent!
|
---|
109 | 0x00}; // VK_BLK2 No equivalent!
|
---|
110 |
|
---|
111 | MRESULT EXPENTRY Win32WindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
|
---|
112 |
|
---|
113 | //******************************************************************************
|
---|
114 | //Initialize PM; create hab, message queue and register special Win32 window classes
|
---|
115 | //******************************************************************************
|
---|
116 | BOOL InitPM()
|
---|
117 | {
|
---|
118 | hab = WinInitialize(0);
|
---|
119 | dprintf(("Winitialize returned %x", hab));
|
---|
120 | hmq = WinCreateMsgQueue(hab, 0);
|
---|
121 |
|
---|
122 | if(!hab || !hmq)
|
---|
123 | {
|
---|
124 | UINT error;
|
---|
125 | //CB: only fail on real error
|
---|
126 | error = WinGetLastError(hab) & 0xFFFF; //error code
|
---|
127 | if (!hab || error != PMERR_MSG_QUEUE_ALREADY_EXISTS)
|
---|
128 | {
|
---|
129 | dprintf(("WinInitialize or WinCreateMsgQueue failed %x %x", hab, hmq));
|
---|
130 | dprintf((" Error = %x",error));
|
---|
131 | return(FALSE);
|
---|
132 | }
|
---|
133 | else
|
---|
134 | {
|
---|
135 | if(!hab) {
|
---|
136 | hab = WinQueryAnchorBlock(HWND_DESKTOP);
|
---|
137 | dprintf(("WinQueryAnchorBlock returned %x", hab));
|
---|
138 | }
|
---|
139 | if(!hmq) {
|
---|
140 | hmq = HMQ_CURRENT;
|
---|
141 | }
|
---|
142 | }
|
---|
143 | }
|
---|
144 | SetThreadHAB(hab);
|
---|
145 | dprintf(("InitPM: hmq = %x", hmq));
|
---|
146 | SetThreadMessageQueue(hmq);
|
---|
147 |
|
---|
148 | if(!WinRegisterClass( /* Register window class */
|
---|
149 | hab, /* Anchor block handle */
|
---|
150 | (PSZ)WIN32_STDCLASS, /* Window class name */
|
---|
151 | (PFNWP)Win32WindowProc, /* Address of window procedure */
|
---|
152 | // CS_SIZEREDRAW | CS_HITTEST | CS_MOVENOTIFY,
|
---|
153 | CS_SIZEREDRAW | CS_HITTEST,
|
---|
154 | NROF_WIN32WNDBYTES)) {
|
---|
155 | dprintf(("WinRegisterClass Win32BaseWindow failed"));
|
---|
156 | return(FALSE);
|
---|
157 | }
|
---|
158 |
|
---|
159 | WinQueryWindowRect(HWND_DESKTOP, &desktopRectl);
|
---|
160 | ScreenWidth = desktopRectl.xRight;
|
---|
161 | ScreenHeight = desktopRectl.yTop;
|
---|
162 |
|
---|
163 | dprintf(("InitPM: Desktop (%d,%d)", ScreenWidth, ScreenHeight));
|
---|
164 | return OSLibInitMsgQueue();
|
---|
165 | } /* End of main */
|
---|
166 | //******************************************************************************
|
---|
167 | //Win32 window message handler
|
---|
168 | //******************************************************************************
|
---|
169 | MRESULT EXPENTRY Win32WindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
170 | {
|
---|
171 | POSTMSG_PACKET *postmsg;
|
---|
172 | OSLIBPOINT point, ClientPoint;
|
---|
173 | Win32BaseWindow *win32wnd;
|
---|
174 | APIRET rc;
|
---|
175 |
|
---|
176 | //Restore our FS selector
|
---|
177 | SetWin32TIB();
|
---|
178 |
|
---|
179 | win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
|
---|
180 |
|
---|
181 | if(msg != WM_CREATE && win32wnd == NULL) {
|
---|
182 | dprintf(("Invalid win32wnd pointer for window %x!!", hwnd));
|
---|
183 | goto RunDefWndProc;
|
---|
184 | }
|
---|
185 | if(msg > WIN32APP_USERMSGBASE) {
|
---|
186 | //win32 app user message
|
---|
187 | return (MRESULT)win32wnd->SendMessageA((ULONG)msg-WIN32APP_USERMSGBASE, (ULONG)mp1, (ULONG)mp2);
|
---|
188 | }
|
---|
189 | switch( msg )
|
---|
190 | {
|
---|
191 | //OS/2 msgs
|
---|
192 | case WM_CREATE:
|
---|
193 | {
|
---|
194 | THDB *thdb = GetThreadTHDB();
|
---|
195 |
|
---|
196 | if(thdb == NULL || thdb->newWindow == 0)
|
---|
197 | goto createfail;
|
---|
198 |
|
---|
199 | //Processing is done in after WinCreateWindow returns
|
---|
200 | dprintf(("OS2: WM_CREATE %x", hwnd));
|
---|
201 | win32wnd = (Win32BaseWindow *)thdb->newWindow;
|
---|
202 |
|
---|
203 | if(win32wnd->MsgCreate(WinQueryWindow(hwnd, QW_PARENT), hwnd) == FALSE)
|
---|
204 | {
|
---|
205 | RestoreOS2TIB();
|
---|
206 | return (MRESULT)TRUE; //discontinue window creation
|
---|
207 | }
|
---|
208 | createfail:
|
---|
209 | RestoreOS2TIB();
|
---|
210 | return (MRESULT)FALSE;
|
---|
211 | }
|
---|
212 |
|
---|
213 | case WM_QUIT:
|
---|
214 | dprintf(("OS2: WM_QUIT %x", hwnd));
|
---|
215 | if(win32wnd->MsgQuit()) {
|
---|
216 | goto RunDefWndProc;
|
---|
217 | }
|
---|
218 | break;
|
---|
219 |
|
---|
220 | case WM_CLOSE:
|
---|
221 | dprintf(("OS2: WM_CLOSE %x", hwnd));
|
---|
222 | // win32wnd->RemoveFakeOpen32();
|
---|
223 | if(win32wnd->MsgClose()) {
|
---|
224 | goto RunDefWndProc;
|
---|
225 | }
|
---|
226 | break;
|
---|
227 |
|
---|
228 | case WM_DESTROY:
|
---|
229 | dprintf(("OS2: WM_DESTROY %x", hwnd));
|
---|
230 | if(win32wnd->MsgDestroy()) {
|
---|
231 | goto RunDefWndProc;
|
---|
232 | }
|
---|
233 | break;
|
---|
234 |
|
---|
235 | case WM_ENABLE:
|
---|
236 | dprintf(("OS2: WM_ENABLE %x", hwnd));
|
---|
237 | if(win32wnd->MsgEnable(SHORT1FROMMP(mp1))) {
|
---|
238 | goto RunDefWndProc;
|
---|
239 | }
|
---|
240 | break;
|
---|
241 |
|
---|
242 | case WM_SHOW:
|
---|
243 | dprintf(("OS2: WM_SHOW %x %d", hwnd, mp1));
|
---|
244 | if(win32wnd->MsgShow((ULONG)mp1)) {
|
---|
245 | goto RunDefWndProc;
|
---|
246 | }
|
---|
247 | break;
|
---|
248 |
|
---|
249 | case WM_ADJUSTWINDOWPOS:
|
---|
250 | {
|
---|
251 | PSWP pswp = (PSWP)mp1;
|
---|
252 | SWP swpOld;
|
---|
253 | WINDOWPOS wp;
|
---|
254 | ULONG parentHeight = 0;
|
---|
255 | HWND hParent = NULLHANDLE, hFrame = NULLHANDLE;
|
---|
256 |
|
---|
257 | dprintf(("OS2: WM_ADJUSTWINDOWPOS %x %x %x (%d,%d) (%d,%d)", hwnd, pswp->hwnd, pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
|
---|
258 |
|
---|
259 | if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0) break;
|
---|
260 | if(!win32wnd->CanReceiveSizeMsgs()) break;
|
---|
261 |
|
---|
262 | WinQueryWindowPos(hwnd, &swpOld);
|
---|
263 |
|
---|
264 | if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
|
---|
265 | if (win32wnd->isChild()) {
|
---|
266 | if(win32wnd->getParent()) {
|
---|
267 | hParent = win32wnd->getParent()->getOS2WindowHandle();
|
---|
268 | }
|
---|
269 | else break;
|
---|
270 | }
|
---|
271 | }
|
---|
272 | hFrame = win32wnd->getOS2FrameWindowHandle();
|
---|
273 | OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, hParent, hFrame);
|
---|
274 |
|
---|
275 | wp.hwnd = win32wnd->getWindowHandle();
|
---|
276 | if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
|
---|
277 | {
|
---|
278 | Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
|
---|
279 | if(wndAfter) wp.hwndInsertAfter = wndAfter->getWindowHandle();
|
---|
280 | }
|
---|
281 | if(win32wnd->MsgPosChanging((LPARAM)&wp) == 0)
|
---|
282 | {//app or default window handler changed wp
|
---|
283 | dprintf(("OS2: WM_ADJUSTWINDOWPOS, app changed windowpos struct"));
|
---|
284 | dprintf(("%x (%d,%d), (%d,%d)", pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
|
---|
285 | OSLibMapWINDOWPOStoSWP(&wp, pswp, &swpOld, hParent, hFrame);
|
---|
286 | dprintf(("%x (%d,%d), (%d,%d)", pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
|
---|
287 | //TODO: What should we return here? 0 means no changes, but the AWP flags
|
---|
288 | // aren't very useful either
|
---|
289 | }
|
---|
290 | break;
|
---|
291 | }
|
---|
292 |
|
---|
293 | case WM_WINDOWPOSCHANGED:
|
---|
294 | {
|
---|
295 | PSWP pswp = (PSWP)mp1;
|
---|
296 | SWP swpOld = *(pswp + 1);
|
---|
297 | WINDOWPOS wp;
|
---|
298 | ULONG parentHeight = 0;
|
---|
299 | HWND hParent = NULLHANDLE, hFrame = NULLHANDLE;
|
---|
300 | LONG yDelta = pswp->cy - swpOld.cy;
|
---|
301 | LONG xDelta = pswp->cx - swpOld.cx;
|
---|
302 |
|
---|
303 | dprintf(("OS2: WM_WINDOWPOSCHANGED %x %x (%d,%d) (%d,%d)", hwnd, pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
|
---|
304 |
|
---|
305 | if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0) break;
|
---|
306 | if(!win32wnd->CanReceiveSizeMsgs()) break;
|
---|
307 |
|
---|
308 | if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
|
---|
309 | if (win32wnd->isChild()) {
|
---|
310 | if(win32wnd->getParent()) {
|
---|
311 | hParent = win32wnd->getParent()->getOS2WindowHandle();
|
---|
312 | }
|
---|
313 | else goto RunDefWndProc; //parent has just been destroyed
|
---|
314 | }
|
---|
315 | }
|
---|
316 | hFrame = WinQueryWindow(hwnd, QW_PARENT);
|
---|
317 | OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, hParent, hFrame);
|
---|
318 |
|
---|
319 | win32wnd->setWindowRect(wp.x, wp.y, wp.x+wp.cx, wp.y+wp.cy);
|
---|
320 | win32wnd->setClientRect(swpOld.x, swpOld.y, swpOld.x + swpOld.cx, swpOld.y + swpOld.cy);
|
---|
321 |
|
---|
322 | wp.hwnd = win32wnd->getWindowHandle();
|
---|
323 | if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
|
---|
324 | {
|
---|
325 | Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
|
---|
326 | wp.hwndInsertAfter = wndAfter->getWindowHandle();
|
---|
327 | }
|
---|
328 |
|
---|
329 | if (yDelta != 0 || xDelta != 0)
|
---|
330 | {
|
---|
331 | HENUM henum = WinBeginEnumWindows(pswp->hwnd);
|
---|
332 | SWP swp[10];
|
---|
333 | int i = 0;
|
---|
334 | HWND hwnd;
|
---|
335 |
|
---|
336 | while ((hwnd = WinGetNextWindow(henum)) != NULLHANDLE)
|
---|
337 | {
|
---|
338 | #if 0
|
---|
339 | if (mdiClient )
|
---|
340 | {
|
---|
341 | continue;
|
---|
342 | }
|
---|
343 | #endif
|
---|
344 | WinQueryWindowPos(hwnd, &(swp[i]));
|
---|
345 |
|
---|
346 | #ifdef DEBUG
|
---|
347 | Win32BaseWindow *window = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
|
---|
348 | dprintf(("ENUMERATE %x delta %d (%d,%d) (%d,%d) %x", (window) ? window->getWindowHandle() : hwnd,
|
---|
349 | yDelta, swp[i].x, swp[i].y, swp[i].cx, swp[i].cy, swp[i].fl));
|
---|
350 | #endif
|
---|
351 |
|
---|
352 | if(swp[i].y != 0) {
|
---|
353 | //child window at offset <> 0 from client area -> offset now changes
|
---|
354 | swp[i].y += yDelta;
|
---|
355 | swp[i].fl &= ~(SWP_NOREDRAW);
|
---|
356 | }
|
---|
357 | //else child window with the same start coorindates as the client area
|
---|
358 | //The app should resize it.
|
---|
359 |
|
---|
360 | if (i == 9)
|
---|
361 | {
|
---|
362 | WinSetMultWindowPos(GetThreadHAB(), swp, 10);
|
---|
363 | i = 0;
|
---|
364 | }
|
---|
365 | else
|
---|
366 | {
|
---|
367 | i++;
|
---|
368 | }
|
---|
369 | }
|
---|
370 |
|
---|
371 | WinEndEnumWindows(henum);
|
---|
372 |
|
---|
373 | if (i)
|
---|
374 | WinSetMultWindowPos(GetThreadHAB(), swp, i);
|
---|
375 | }
|
---|
376 | if (yDelta != 0)
|
---|
377 | {
|
---|
378 | POINT pt;
|
---|
379 | if(GetCaretPos (&pt) == TRUE)
|
---|
380 | {
|
---|
381 | pt.y -= yDelta;
|
---|
382 | SetCaretPos (pt.x, pt.y);
|
---|
383 | }
|
---|
384 | }
|
---|
385 | win32wnd->MsgPosChanged((LPARAM)&wp);
|
---|
386 |
|
---|
387 | goto RunDefWndProc;
|
---|
388 | }
|
---|
389 |
|
---|
390 | case WM_MOVE:
|
---|
391 | {
|
---|
392 | if (!win32wnd->isFrameWindow()) break;
|
---|
393 |
|
---|
394 | HWND hFrame = win32wnd->getOS2FrameWindowHandle();
|
---|
395 | SWP swp, swpo;
|
---|
396 | WINDOWPOS wp;
|
---|
397 | ULONG parentHeight = 0;
|
---|
398 | RECTL rcl;
|
---|
399 |
|
---|
400 | WinQueryWindowRect (hwnd, &rcl);
|
---|
401 | WinMapWindowPoints (hwnd, hFrame, (PPOINTL)&rcl, 2);
|
---|
402 | swp.x = swpo.x = rcl.xLeft;
|
---|
403 | swp.y = swpo.y = rcl.yBottom;
|
---|
404 | swp.cx = swpo.cx = rcl.xRight - rcl.xLeft;
|
---|
405 | swp.cy = swpo.cy = rcl.yTop - rcl.yBottom;
|
---|
406 | swp.fl = SWP_MOVE | SWP_NOREDRAW;
|
---|
407 | swp.hwnd = hwnd;
|
---|
408 | swp.hwndInsertBehind = NULLHANDLE;
|
---|
409 | dprintf(("OS2: WM_MOVE %x %x (%d,%d) (%d,%d)", hwnd, swp.fl, swp.x, swp.y, swp.cx, swp.cy));
|
---|
410 |
|
---|
411 | OSLibMapSWPtoWINDOWPOS(&swp, &wp, &swpo, NULLHANDLE, hFrame);
|
---|
412 |
|
---|
413 | wp.flags &= ~SWP_NOMOVE_W;
|
---|
414 | wp.hwnd = win32wnd->getWindowHandle();
|
---|
415 | win32wnd->setWindowRect(wp.x, wp.y, wp.x + wp.cx, wp.y + wp.cy);
|
---|
416 | win32wnd->setClientRect(swpo.x, swpo.y, swpo.x + swpo.cx, swpo.y + swpo.cy);
|
---|
417 | win32wnd->MsgPosChanged((LPARAM)&wp);
|
---|
418 | break;
|
---|
419 | }
|
---|
420 |
|
---|
421 | case WM_SIZE:
|
---|
422 | {
|
---|
423 | break;
|
---|
424 | }
|
---|
425 |
|
---|
426 | case WM_ACTIVATE:
|
---|
427 | {
|
---|
428 | HWND hwndActivate = (HWND)mp2;
|
---|
429 | BOOL fMinimized = FALSE;
|
---|
430 |
|
---|
431 | dprintf(("OS2: WM_ACTIVATE %x %x", hwnd, hwndActivate));
|
---|
432 | if(WinQueryWindowULong(hwndActivate, OFFSET_WIN32PM_MAGIC) != WIN32PM_MAGIC) {
|
---|
433 | //another (non-win32) application's window
|
---|
434 | //set to NULL (allowed according to win32 SDK) to avoid problems
|
---|
435 | hwndActivate = NULL;
|
---|
436 | }
|
---|
437 | if(WinQueryWindowULong(hwnd, QWL_STYLE) & WS_MINIMIZED)
|
---|
438 | {
|
---|
439 | fMinimized = TRUE;
|
---|
440 | }
|
---|
441 |
|
---|
442 | if(win32wnd->MsgActivate(SHORT1FROMMP(mp1), fMinimized, Win32BaseWindow::OS2ToWin32Handle(hwndActivate))) {
|
---|
443 | goto RunDefWndProc;
|
---|
444 | }
|
---|
445 | break;
|
---|
446 | }
|
---|
447 | case WM_FOCUSCHANGE:
|
---|
448 | dprintf(("OS2: WM_FOCUSCHANGE %x", hwnd));
|
---|
449 | goto RunDefWndProc;
|
---|
450 |
|
---|
451 | case WM_SETFOCUS:
|
---|
452 | {
|
---|
453 | HWND hwndFocus = (HWND)mp1;
|
---|
454 |
|
---|
455 | dprintf(("OS2: WM_SETFOCUS %x %d", hwnd, mp2));
|
---|
456 | if(WinQueryWindowULong(hwndFocus, OFFSET_WIN32PM_MAGIC) != WIN32PM_MAGIC) {
|
---|
457 | //another (non-win32) application's window
|
---|
458 | //set to NULL (allowed according to win32 SDK) to avoid problems
|
---|
459 | hwndFocus = NULL;
|
---|
460 | }
|
---|
461 | if((ULONG)mp2 == TRUE) {
|
---|
462 | HWND hwndFocusWin32 = Win32BaseWindow::OS2ToWin32Handle(hwndFocus);
|
---|
463 | recreateCaret (hwndFocusWin32);
|
---|
464 | rc = win32wnd->MsgSetFocus(hwndFocusWin32);
|
---|
465 | }
|
---|
466 | else rc = win32wnd->MsgKillFocus(Win32BaseWindow::OS2ToWin32Handle(hwndFocus));
|
---|
467 | if(rc) {
|
---|
468 | goto RunDefWndProc;
|
---|
469 | }
|
---|
470 | break;
|
---|
471 | }
|
---|
472 | //**************************************************************************
|
---|
473 | //Mouse messages (OS/2 Window coordinates -> Win32 coordinates relative to screen
|
---|
474 | //**************************************************************************
|
---|
475 | case WM_BUTTON1DOWN:
|
---|
476 | dprintf(("OS2: WM_BUTTON1DOWN %x", hwnd));
|
---|
477 | point.x = (*(POINTS *)&mp1).x;
|
---|
478 | point.y = (*(POINTS *)&mp1).y;
|
---|
479 | ClientPoint.x = point.x;
|
---|
480 | ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
|
---|
481 | MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
|
---|
482 | if(win32wnd->MsgButton(BUTTON_LEFTDOWN, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
|
---|
483 | goto RunDefWndProc;
|
---|
484 | }
|
---|
485 | break;
|
---|
486 |
|
---|
487 | case WM_BUTTON1UP:
|
---|
488 | dprintf(("OS2: WM_BUTTON1UP %x", hwnd));
|
---|
489 | point.x = (*(POINTS *)&mp1).x;
|
---|
490 | point.y = (*(POINTS *)&mp1).y;
|
---|
491 | ClientPoint.x = point.x;
|
---|
492 | ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
|
---|
493 | MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
|
---|
494 | if(win32wnd->MsgButton(BUTTON_LEFTUP, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
|
---|
495 | goto RunDefWndProc;
|
---|
496 | }
|
---|
497 | break;
|
---|
498 | case WM_BUTTON1DBLCLK:
|
---|
499 | point.x = (*(POINTS *)&mp1).x;
|
---|
500 | point.y = (*(POINTS *)&mp1).y;
|
---|
501 | ClientPoint.x = point.x;
|
---|
502 | ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
|
---|
503 | MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
|
---|
504 | if(win32wnd->MsgButton(BUTTON_LEFTDBLCLICK, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
|
---|
505 | goto RunDefWndProc;
|
---|
506 | }
|
---|
507 | break;
|
---|
508 | case WM_BUTTON2DOWN:
|
---|
509 | point.x = (*(POINTS *)&mp1).x;
|
---|
510 | point.y = (*(POINTS *)&mp1).y;
|
---|
511 | ClientPoint.x = point.x;
|
---|
512 | ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
|
---|
513 | MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
|
---|
514 | if(win32wnd->MsgButton(BUTTON_RIGHTDOWN, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
|
---|
515 | goto RunDefWndProc;
|
---|
516 | }
|
---|
517 | break;
|
---|
518 | case WM_BUTTON2UP:
|
---|
519 | point.x = (*(POINTS *)&mp1).x;
|
---|
520 | point.y = (*(POINTS *)&mp1).y;
|
---|
521 | ClientPoint.x = point.x;
|
---|
522 | ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
|
---|
523 | MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
|
---|
524 | if(win32wnd->MsgButton(BUTTON_RIGHTUP, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
|
---|
525 | goto RunDefWndProc;
|
---|
526 | }
|
---|
527 | break;
|
---|
528 | case WM_BUTTON2DBLCLK:
|
---|
529 | point.x = (*(POINTS *)&mp1).x;
|
---|
530 | point.y = (*(POINTS *)&mp1).y;
|
---|
531 | ClientPoint.x = point.x;
|
---|
532 | ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
|
---|
533 | MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
|
---|
534 | if(win32wnd->MsgButton(BUTTON_RIGHTDBLCLICK, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
|
---|
535 | goto RunDefWndProc;
|
---|
536 | }
|
---|
537 | break;
|
---|
538 | case WM_BUTTON3DOWN:
|
---|
539 | point.x = (*(POINTS *)&mp1).x;
|
---|
540 | point.y = (*(POINTS *)&mp1).y;
|
---|
541 | ClientPoint.x = point.x;
|
---|
542 | ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
|
---|
543 | MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
|
---|
544 | if(win32wnd->MsgButton(BUTTON_MIDDLEDOWN, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
|
---|
545 | goto RunDefWndProc;
|
---|
546 | }
|
---|
547 | break;
|
---|
548 | case WM_BUTTON3UP:
|
---|
549 | point.x = (*(POINTS *)&mp1).x;
|
---|
550 | point.y = (*(POINTS *)&mp1).y;
|
---|
551 | ClientPoint.x = point.x;
|
---|
552 | ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
|
---|
553 | MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
|
---|
554 | if(win32wnd->MsgButton(BUTTON_MIDDLEUP, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
|
---|
555 | goto RunDefWndProc;
|
---|
556 | }
|
---|
557 | break;
|
---|
558 | case WM_BUTTON3DBLCLK:
|
---|
559 | point.x = (*(POINTS *)&mp1).x;
|
---|
560 | point.y = (*(POINTS *)&mp1).y;
|
---|
561 | ClientPoint.x = point.x;
|
---|
562 | ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
|
---|
563 | MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
|
---|
564 | if(win32wnd->MsgButton(BUTTON_MIDDLEDBLCLICK, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
|
---|
565 | goto RunDefWndProc;
|
---|
566 | }
|
---|
567 | break;
|
---|
568 |
|
---|
569 | case WM_BUTTON2MOTIONSTART:
|
---|
570 | case WM_BUTTON2MOTIONEND:
|
---|
571 | case WM_BUTTON2CLICK:
|
---|
572 | case WM_BUTTON1MOTIONSTART:
|
---|
573 | case WM_BUTTON1MOTIONEND:
|
---|
574 | case WM_BUTTON1CLICK:
|
---|
575 | case WM_BUTTON3MOTIONSTART:
|
---|
576 | case WM_BUTTON3MOTIONEND:
|
---|
577 | case WM_BUTTON3CLICK:
|
---|
578 | goto RunDefWndProc;
|
---|
579 |
|
---|
580 | case WM_MOUSEMOVE:
|
---|
581 | {
|
---|
582 | ULONG keystate = 0;
|
---|
583 | if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON1))
|
---|
584 | keystate |= WMMOVE_LBUTTON;
|
---|
585 | if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON2))
|
---|
586 | keystate |= WMMOVE_MBUTTON;
|
---|
587 | if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON3))
|
---|
588 | keystate |= WMMOVE_RBUTTON;
|
---|
589 | if(WinGetKeyState(HWND_DESKTOP, VK_SHIFT))
|
---|
590 | keystate |= WMMOVE_SHIFT;
|
---|
591 | if(WinGetKeyState(HWND_DESKTOP, VK_CTRL))
|
---|
592 | keystate |= WMMOVE_CTRL;
|
---|
593 |
|
---|
594 | //OS/2 Window coordinates -> Win32 Window coordinates
|
---|
595 | if(win32wnd->MsgMouseMove(keystate, SHORT1FROMMP(mp1), MapOS2ToWin32Y(win32wnd, SHORT2FROMMP(mp1))))
|
---|
596 | {
|
---|
597 | //Changes mouse cursor to default
|
---|
598 | goto RunDefWndProc;
|
---|
599 | }
|
---|
600 | break;
|
---|
601 | }
|
---|
602 |
|
---|
603 | case WM_CONTROL:
|
---|
604 |
|
---|
605 | case WM_COMMAND:
|
---|
606 | if(SHORT1FROMMP(mp2) == CMDSRC_MENU) {
|
---|
607 | win32wnd->MsgCommand(CMD_MENU, SHORT1FROMMP(mp1), 0);
|
---|
608 | }
|
---|
609 | if(SHORT1FROMMP(mp2) == CMDSRC_ACCELERATOR) {
|
---|
610 | win32wnd->MsgCommand(CMD_ACCELERATOR, SHORT1FROMMP(mp1), 0);
|
---|
611 | }
|
---|
612 | //todo controls + accelerators
|
---|
613 | break;
|
---|
614 |
|
---|
615 | case WM_SYSCOMMAND:
|
---|
616 | {
|
---|
617 | ULONG x = 0, y = 0;
|
---|
618 | ULONG win32sc;
|
---|
619 |
|
---|
620 | if(SHORT2FROMMP(mp2) == TRUE) {//syscommand caused by mouse action
|
---|
621 | POINTL pointl;
|
---|
622 | WinQueryPointerPos(HWND_DESKTOP, &pointl);
|
---|
623 | x = pointl.x;
|
---|
624 | y = ScreenHeight - y;
|
---|
625 | }
|
---|
626 | switch(SHORT1FROMMP(mp1)) {
|
---|
627 | case SC_MOVE:
|
---|
628 | win32sc = SC_MOVE_W;
|
---|
629 | break;
|
---|
630 | case SC_CLOSE:
|
---|
631 | win32sc = SC_CLOSE_W;
|
---|
632 | break;
|
---|
633 | case SC_MAXIMIZE:
|
---|
634 | win32sc = SC_MAXIMIZE_W;
|
---|
635 | break;
|
---|
636 | case SC_MINIMIZE:
|
---|
637 | win32sc = SC_MINIMIZE_W;
|
---|
638 | break;
|
---|
639 | case SC_NEXTFRAME:
|
---|
640 | case SC_NEXTWINDOW:
|
---|
641 | win32sc = SC_NEXTWINDOW_W;
|
---|
642 | break;
|
---|
643 | case SC_RESTORE:
|
---|
644 | win32sc = SC_RESTORE_W;
|
---|
645 | break;
|
---|
646 | case SC_TASKMANAGER:
|
---|
647 | win32sc = SC_TASKLIST_W;
|
---|
648 | break;
|
---|
649 | default:
|
---|
650 | goto RunDefWndProc;
|
---|
651 | }
|
---|
652 | dprintf(("WM_SYSCOMMAND %x %x (%d,%d)", hwnd, win32sc, x, y));
|
---|
653 | if(win32wnd->MsgSysCommand(win32sc, x, y)) {
|
---|
654 | goto RunDefWndProc;
|
---|
655 | }
|
---|
656 | break;
|
---|
657 | }
|
---|
658 | case WM_CHAR:
|
---|
659 | {
|
---|
660 | THDB *thdb;
|
---|
661 | ULONG repeatCount=0, virtualKey=0, keyFlags=0, scanCode=0;
|
---|
662 | ULONG flags = SHORT1FROMMP(mp1);
|
---|
663 | BOOL keyWasPressed, fTranslated = FALSE, fRunDefWndProc = FALSE;
|
---|
664 | char c;
|
---|
665 |
|
---|
666 | repeatCount = CHAR3FROMMP(mp1);
|
---|
667 | scanCode = CHAR4FROMMP(mp1);
|
---|
668 | keyWasPressed = ((SHORT1FROMMP (mp1) & KC_PREVDOWN) == KC_PREVDOWN);
|
---|
669 |
|
---|
670 | // both WM_KEYUP & WM_KEYDOWN want a virtual key, find the right Win32 virtual key
|
---|
671 | // given the OS/2 virtual key and OS/2 character
|
---|
672 |
|
---|
673 | if (((SHORT1FROMMP (mp1) & KC_CHAR) == KC_CHAR) ||
|
---|
674 | ((SHORT1FROMMP (mp1) & KC_LONEKEY) == KC_LONEKEY))
|
---|
675 | {
|
---|
676 | c = SHORT1FROMMP (mp2);
|
---|
677 | if ((c >= 'A') && (c <= 'Z')) {
|
---|
678 | virtualKey = c;
|
---|
679 | goto VirtualKeyFound;
|
---|
680 | }
|
---|
681 | if ((c >='a') && (c <= 'z')) {
|
---|
682 | virtualKey = c - 32; // make it uppercase
|
---|
683 | goto VirtualKeyFound;
|
---|
684 | }
|
---|
685 | if ((c >= '0') && (c <= '9')) {
|
---|
686 | virtualKey = c;
|
---|
687 | goto VirtualKeyFound;
|
---|
688 | }
|
---|
689 | }
|
---|
690 |
|
---|
691 | // convert OS/2 virtual keys to Win32 virtual key
|
---|
692 | if (SHORT2FROMMP (mp2) <= VK_BLK2)
|
---|
693 | virtualKey = virtualKeyTable [SHORT2FROMMP (mp2)];
|
---|
694 |
|
---|
695 | VirtualKeyFound:
|
---|
696 |
|
---|
697 | if(!(SHORT1FROMMP(mp1) & KC_ALT))
|
---|
698 | {
|
---|
699 | //
|
---|
700 | // the Alt key is not pressed
|
---|
701 | //
|
---|
702 | if ((flags & KC_KEYUP) == KC_KEYUP) {
|
---|
703 | // send WM_KEYUP message
|
---|
704 |
|
---|
705 | if(win32wnd->MsgKeyUp (repeatCount, scanCode, virtualKey)) {
|
---|
706 | fRunDefWndProc = TRUE;
|
---|
707 | }
|
---|
708 | }
|
---|
709 | else {
|
---|
710 | // send WM_KEYDOWN message
|
---|
711 | if (win32wnd->MsgKeyDown (repeatCount, scanCode, virtualKey, keyWasPressed))
|
---|
712 | fRunDefWndProc = TRUE;
|
---|
713 | }
|
---|
714 | }
|
---|
715 | else {
|
---|
716 | //
|
---|
717 | // the Alt key is pressed
|
---|
718 | //
|
---|
719 | if ((flags & KC_KEYUP) == KC_KEYUP) {
|
---|
720 | // send WM_SYSKEYUP message
|
---|
721 |
|
---|
722 | if(win32wnd->MsgSysKeyUp (repeatCount, scanCode, virtualKey)) {
|
---|
723 | fRunDefWndProc = TRUE;
|
---|
724 | }
|
---|
725 | }
|
---|
726 | else {
|
---|
727 | // send WM_SYSKEYDOWN message
|
---|
728 | if (win32wnd->MsgSysKeyDown (repeatCount, scanCode, virtualKey, keyWasPressed))
|
---|
729 | fRunDefWndProc = TRUE;
|
---|
730 | }
|
---|
731 | }
|
---|
732 |
|
---|
733 | thdb = GetThreadTHDB();
|
---|
734 | if(thdb) {
|
---|
735 | fTranslated = thdb->fMsgTranslated;
|
---|
736 | thdb->fMsgTranslated = FALSE; //reset flag
|
---|
737 | }
|
---|
738 | //NOTE: These actually need to be posted so that the next message retrieved by GetMessage contains
|
---|
739 | // the newly generated WM_CHAR message.
|
---|
740 | if(fTranslated && !((flags & KC_KEYUP) == KC_KEYUP)) {//TranslatedMessage was called before DispatchMessage, so send WM_CHAR messages
|
---|
741 | ULONG keyflags = 0, vkey = 0;
|
---|
742 | ULONG fl = SHORT1FROMMP(mp1);
|
---|
743 |
|
---|
744 | if(!(fl & KC_CHAR)) {
|
---|
745 | goto RunDefWndProc;
|
---|
746 | }
|
---|
747 | if(fl & KC_VIRTUALKEY) {
|
---|
748 | vkey = SHORT2FROMMP(mp2);
|
---|
749 | }
|
---|
750 | if(fl & KC_KEYUP) {
|
---|
751 | keyflags |= KEY_UP;
|
---|
752 | }
|
---|
753 | if(fl & KC_ALT) {
|
---|
754 | keyflags |= KEY_ALTDOWN;
|
---|
755 | }
|
---|
756 | if(fl & KC_PREVDOWN) {
|
---|
757 | keyflags |= KEY_PREVDOWN;
|
---|
758 | }
|
---|
759 | if(fl & KC_DEADKEY) {
|
---|
760 | keyflags |= KEY_DEADKEY;
|
---|
761 | }
|
---|
762 | if(win32wnd->MsgChar(SHORT1FROMMP(mp2), CHAR3FROMMP(mp1), CHAR4FROMMP(mp1), virtualKey, keyflags)) {
|
---|
763 | goto RunDefWndProc;
|
---|
764 | }
|
---|
765 | }
|
---|
766 | if(fRunDefWndProc) goto RunDefWndProc;
|
---|
767 | break;
|
---|
768 | }
|
---|
769 |
|
---|
770 | case WM_INITMENU:
|
---|
771 | case WM_MENUSELECT:
|
---|
772 | case WM_MENUEND:
|
---|
773 | case WM_NEXTMENU:
|
---|
774 | goto RunDefWndProc;
|
---|
775 |
|
---|
776 | case WM_TIMER:
|
---|
777 | if (mp2) win32wnd->MsgTimer((ULONG)mp1);
|
---|
778 | goto RunDefWndProc;
|
---|
779 |
|
---|
780 | case WM_SETWINDOWPARAMS:
|
---|
781 | {
|
---|
782 | WNDPARAMS *wndParams = (WNDPARAMS *)mp1;
|
---|
783 |
|
---|
784 | dprintf(("OS2: WM_SETWINDOWPARAMS %x", hwnd));
|
---|
785 | if(wndParams->fsStatus & WPM_TEXT) {
|
---|
786 | if(win32wnd->MsgSetText(wndParams->pszText, wndParams->cchText)) {
|
---|
787 | goto RunDefWndProc;
|
---|
788 | }
|
---|
789 | }
|
---|
790 | goto RunDefWndProc;
|
---|
791 | }
|
---|
792 |
|
---|
793 | case WM_QUERYWINDOWPARAMS:
|
---|
794 | {
|
---|
795 | PWNDPARAMS wndpars = (PWNDPARAMS)mp1;
|
---|
796 | ULONG textlen;
|
---|
797 | PSZ wintext;
|
---|
798 |
|
---|
799 | if(wndpars->fsStatus & (WPM_CCHTEXT | WPM_TEXT))
|
---|
800 | {
|
---|
801 | if(wndpars->fsStatus & WPM_CCHTEXT)
|
---|
802 | wndpars->cchText = win32wnd->MsgGetTextLength();
|
---|
803 | if(wndpars->fsStatus & WPM_TEXT)
|
---|
804 | wndpars->pszText = win32wnd->MsgGetText();
|
---|
805 |
|
---|
806 | wndpars->fsStatus = 0;
|
---|
807 | wndpars->cbCtlData = 0;
|
---|
808 | wndpars->cbPresParams = 0;
|
---|
809 | RestoreOS2TIB();
|
---|
810 | return (MRESULT)TRUE;
|
---|
811 | }
|
---|
812 | goto RunDefWndProc;
|
---|
813 | }
|
---|
814 |
|
---|
815 | case WM_ERASEBACKGROUND:
|
---|
816 | {
|
---|
817 | dprintf(("OS2: WM_ERASEBACKGROUND %x", win32wnd->getWindowHandle()));
|
---|
818 | if (WinQueryUpdateRect (hwnd, NULL) && !win32wnd->isSupressErase()) {
|
---|
819 | BOOL erased = sendEraseBkgnd (win32wnd);
|
---|
820 | win32wnd->setEraseBkgnd (!erased, !erased);
|
---|
821 | }
|
---|
822 |
|
---|
823 | break;
|
---|
824 | }
|
---|
825 |
|
---|
826 | case WM_PAINT:
|
---|
827 | dprintf(("OS2: WM_PAINT %x", hwnd));
|
---|
828 |
|
---|
829 | if (WinQueryUpdateRect (hwnd, NULL)) {
|
---|
830 | if (!win32wnd->isSupressErase()) {
|
---|
831 | BOOL erased = sendEraseBkgnd (win32wnd);
|
---|
832 | win32wnd->setEraseBkgnd (!erased, !erased);
|
---|
833 | }
|
---|
834 | }
|
---|
835 | win32wnd->setSupressErase (FALSE);
|
---|
836 |
|
---|
837 | if(win32wnd->MsgPaint(0, 0)) {
|
---|
838 | goto RunDefWndProc;
|
---|
839 | }
|
---|
840 | break;
|
---|
841 |
|
---|
842 | case WM_HITTEST:
|
---|
843 | // Only send this message if the window is enabled
|
---|
844 | if (WinIsWindowEnabled(hwnd))
|
---|
845 | {
|
---|
846 | if(win32wnd->MsgHitTest((*(POINTS *)&mp1).x, MapOS2ToWin32Y(OSLIB_HWND_DESKTOP, hwnd, (*(POINTS *)&mp1).y))) {
|
---|
847 | goto RunDefWndProc;
|
---|
848 | }
|
---|
849 | }
|
---|
850 | else goto RunDefWndProc;
|
---|
851 | break;
|
---|
852 |
|
---|
853 | case WM_SYSCOLORCHANGE:
|
---|
854 | case WM_SYSVALUECHANGED:
|
---|
855 | case WM_CALCVALIDRECTS:
|
---|
856 | case WM_SETSELECTION:
|
---|
857 | case WM_PPAINT:
|
---|
858 | case WM_PSETFOCUS:
|
---|
859 | case WM_PSYSCOLORCHANGE:
|
---|
860 | case WM_PSIZE:
|
---|
861 | case WM_PACTIVATE:
|
---|
862 | case WM_PCONTROL:
|
---|
863 | case WM_HELP:
|
---|
864 | case WM_APPTERMINATENOTIFY:
|
---|
865 | case WM_PRESPARAMCHANGED:
|
---|
866 | case WM_DRAWITEM:
|
---|
867 | case WM_MEASUREITEM:
|
---|
868 | case WM_CONTROLPOINTER:
|
---|
869 | case WM_QUERYDLGCODE:
|
---|
870 | case WM_SUBSTITUTESTRING:
|
---|
871 | case WM_MATCHMNEMONIC:
|
---|
872 | case WM_SAVEAPPLICATION:
|
---|
873 | case WM_SEMANTICEVENT:
|
---|
874 | default:
|
---|
875 | // dprintf(("OS2: RunDefWndProc msg %x for %x", msg, hwnd));
|
---|
876 | RestoreOS2TIB();
|
---|
877 | return WinDefWindowProc( hwnd, msg, mp1, mp2 );
|
---|
878 | }
|
---|
879 | RestoreOS2TIB();
|
---|
880 | return (MRESULT)FALSE;
|
---|
881 |
|
---|
882 | RunDefWndProc:
|
---|
883 | // dprintf(("OS2: RunDefWndProc msg %x for %x", msg, hwnd));
|
---|
884 | RestoreOS2TIB();
|
---|
885 | return WinDefWindowProc( hwnd, msg, mp1, mp2 );
|
---|
886 | } /* End of Win32WindowProc */
|
---|
887 | //******************************************************************************
|
---|
888 | //******************************************************************************
|
---|
889 | MRESULT EXPENTRY Win32SubclassWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
890 | {
|
---|
891 | Win32BaseWindow* win32wnd;
|
---|
892 |
|
---|
893 | //Restore our FS selector
|
---|
894 | SetWin32TIB();
|
---|
895 |
|
---|
896 | win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
|
---|
897 |
|
---|
898 | if (!win32wnd)
|
---|
899 | {
|
---|
900 | dprintf(("Invalid win32wnd pointer for subclassed window %x!!", hwnd));
|
---|
901 | goto RunDefWndProc;
|
---|
902 | }
|
---|
903 |
|
---|
904 | switch (msg)
|
---|
905 | {
|
---|
906 | case WM_WINDOWPOSCHANGED:
|
---|
907 | {
|
---|
908 | PSWP pswp = (PSWP)mp1;
|
---|
909 | SWP swpOld = *(pswp + 1);
|
---|
910 | WINDOWPOS wp;
|
---|
911 | HWND hParent = NULLHANDLE, hFrame = NULLHANDLE;
|
---|
912 |
|
---|
913 | dprintf(("OS2Subclass: WM_WINDOWPOSCHANGED %x %x (%d,%d) (%d,%d)", hwnd, pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
|
---|
914 | if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0) break;
|
---|
915 |
|
---|
916 | hParent = hFrame = WinQueryWindow(hwnd, QW_PARENT);
|
---|
917 |
|
---|
918 | OSLibMapSWPtoWINDOWPOS(pswp,&wp, &swpOld,hParent,hFrame);
|
---|
919 |
|
---|
920 | win32wnd->setWindowRect(swpOld.x, swpOld.y, swpOld.x + swpOld.cx, swpOld.y + swpOld.cy);
|
---|
921 | win32wnd->setClientRect(swpOld.x, swpOld.y, swpOld.x + swpOld.cx, swpOld.y + swpOld.cy);
|
---|
922 | wp.x = swpOld.x;
|
---|
923 | wp.y = swpOld.y;
|
---|
924 | wp.cx = swpOld.cx;
|
---|
925 | wp.cy = swpOld.cy;
|
---|
926 |
|
---|
927 | wp.hwnd = win32wnd->getWindowHandle();
|
---|
928 |
|
---|
929 | win32wnd->MsgPosChanged((LPARAM)&wp);
|
---|
930 |
|
---|
931 | goto RunOldWndProc;
|
---|
932 | }
|
---|
933 |
|
---|
934 | default:
|
---|
935 | goto RunDefHandler;
|
---|
936 | }
|
---|
937 |
|
---|
938 | RunDefWndProc:
|
---|
939 | RestoreOS2TIB();
|
---|
940 | return WinDefWindowProc(hwnd,msg,mp1,mp2);
|
---|
941 |
|
---|
942 | RunOldWndProc:
|
---|
943 | RestoreOS2TIB();
|
---|
944 | return ((PFNWP)win32wnd->getOldWndProc())(hwnd,msg,mp1,mp2);
|
---|
945 |
|
---|
946 | RunDefHandler:
|
---|
947 | RestoreOS2TIB();
|
---|
948 | return Win32WindowProc(hwnd,msg,mp1,mp2);
|
---|
949 | }
|
---|
950 |
|
---|
951 | PVOID SubclassWithDefHandler(HWND hwnd)
|
---|
952 | {
|
---|
953 | return WinSubclassWindow(hwnd,Win32SubclassWindowProc);
|
---|
954 | }
|
---|