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