source: trunk/src/user32/pmwindow.cpp@ 1005

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

Rene Pronk's WM_(SYS)KEYUP/DOWN changes + SvL's dialog changes

File size: 26.1 KB
Line 
1/* $Id: pmwindow.cpp,v 1.5 1999-09-22 08:58:35 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 "pmwindow.h"
25#include "oslibwin.h"
26#include "oslibutil.h"
27#include "oslibgdi.h"
28#include "oslibmsg.h"
29#include "dc.h"
30
31HMQ hmq = 0; /* Message queue handle */
32HAB hab = 0;
33
34RECTL desktopRectl = {0};
35ULONG ScreenWidth = 0;
36ULONG ScreenHeight = 0;
37
38MRESULT EXPENTRY Win32WindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
39
40//******************************************************************************
41//Initialize PM; create hab, message queue and register special Win32 window classes
42//******************************************************************************
43BOOL InitPM()
44{
45 hab = WinInitialize(0);
46 dprintf(("Winitialize returned %x", hab));
47 hmq = WinCreateMsgQueue(hab, 0);
48
49 if(!hab || !hmq)
50 {
51 UINT error;
52 //CB: only fail on real error
53 error = WinGetLastError(hab) & 0xFFFF; //error code
54 if (!hab || error != PMERR_MSG_QUEUE_ALREADY_EXISTS)
55 {
56 dprintf(("WinInitialize or WinCreateMsgQueue failed %x %x", hab, hmq));
57 dprintf((" Error = %x",error));
58 return(FALSE);
59 }
60 else
61 {
62 if(!hab) {
63 hab = WinQueryAnchorBlock(HWND_DESKTOP);
64 dprintf(("WinQueryAnchorBlock returned %x", hab));
65 }
66 if(!hmq) {
67 hmq = HMQ_CURRENT;
68 }
69 }
70 }
71 SetThreadHAB(hab);
72 dprintf(("InitPM: hmq = %x", hmq));
73 SetThreadMessageQueue(hmq);
74
75 if(!WinRegisterClass( /* Register window class */
76 hab, /* Anchor block handle */
77 (PSZ)WIN32_STDCLASS, /* Window class name */
78 (PFNWP)Win32WindowProc, /* Address of window procedure */
79 CS_SIZEREDRAW | CS_HITTEST,
80 NROF_WIN32WNDBYTES)) {
81 dprintf(("WinRegisterClass Win32BaseWindow failed"));
82 return(FALSE);
83 }
84
85 WinQueryWindowRect(HWND_DESKTOP, &desktopRectl);
86 ScreenWidth = desktopRectl.xRight;
87 ScreenHeight = desktopRectl.yTop;
88
89 dprintf(("InitPM: Desktop (%d,%d)", ScreenWidth, ScreenHeight));
90 return OSLibInitMsgQueue();
91} /* End of main */
92//******************************************************************************
93//Win32 window message handler
94//******************************************************************************
95MRESULT EXPENTRY Win32WindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
96{
97 POSTMSG_PACKET *postmsg;
98 OSLIBPOINT point, ClientPoint;
99 Win32BaseWindow *win32wnd;
100 APIRET rc;
101
102 //Restore our FS selector
103 SetWin32TIB();
104
105 win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
106
107 if(msg != WM_CREATE && win32wnd == NULL) {
108 dprintf(("Invalid win32wnd pointer for window %x!!", hwnd));
109 goto RunDefWndProc;
110 }
111 if(msg > WIN32APP_USERMSGBASE) {
112 //win32 app user message
113 dprintf(("PMWINDOW: Message %x (%x,%x) posted to window %x", (ULONG)msg-WIN32APP_USERMSGBASE, mp1, mp2, hwnd));
114 win32wnd->SendMessageA((ULONG)msg-WIN32APP_USERMSGBASE, (ULONG)mp1, (ULONG)mp2);
115 }
116 switch( msg )
117 {
118 //OS/2 msgs
119 case WM_CREATE:
120 //Processing is done in after WinCreateWindow returns
121 dprintf(("OS2: WM_CREATE %x", hwnd));
122 RestoreOS2TIB();
123 return (MRESULT)FALSE;
124
125 case WM_QUIT:
126 dprintf(("OS2: WM_QUIT %x", hwnd));
127 if(win32wnd->MsgQuit()) {
128 goto RunDefWndProc;
129 }
130 break;
131
132 case WM_CLOSE:
133 dprintf(("OS2: WM_CLOSE %x", hwnd));
134// win32wnd->RemoveFakeOpen32();
135 if(win32wnd->MsgClose()) {
136 goto RunDefWndProc;
137 }
138 break;
139
140 case WM_DESTROY:
141 dprintf(("OS2: WM_DESTROY %x", hwnd));
142 if(win32wnd->MsgDestroy()) {
143 goto RunDefWndProc;
144 }
145 break;
146
147 case WM_ENABLE:
148 dprintf(("OS2: WM_ENABLE %x", hwnd));
149 if(win32wnd->MsgEnable((ULONG)mp1)) {
150 goto RunDefWndProc;
151 }
152 break;
153
154 case WM_SHOW:
155 dprintf(("OS2: WM_SHOW %x", hwnd));
156 if(win32wnd->MsgShow((ULONG)mp1)) {
157 goto RunDefWndProc;
158 }
159 break;
160
161 case WM_ADJUSTWINDOWPOS:
162 {
163 PSWP pswp = (PSWP)mp1;
164 SWP swpOld;
165 WINDOWPOS wp;
166 ULONG parentHeight = 0;
167 HWND hParent = NULLHANDLE, hFrame = NULLHANDLE;
168
169 dprintf(("OS2: WM_ADJUSTWINDOWPOS %x %x (%d,%d) (%d,%d)", hwnd, pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
170
171 if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0) break;
172
173 WinQueryWindowPos(hwnd, &swpOld);
174
175 if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
176 if (win32wnd->isChild())
177 hParent = win32wnd->getParent()->getOS2WindowHandle();
178 else
179 hFrame = win32wnd->getOS2FrameWindowHandle();
180 }
181 OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, hParent, hFrame);
182
183 wp.hwnd = win32wnd->getWindowHandle();
184 if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
185 {
186 Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
187 if(wndAfter) wp.hwndInsertAfter = wndAfter->getWindowHandle();
188 }
189 win32wnd->MsgPosChanging((LPARAM)&wp);
190 break;
191 }
192
193 case WM_WINDOWPOSCHANGED:
194 {
195 PSWP pswp = (PSWP)mp1;
196 PSWP pswpo = pswp + 1;
197 WINDOWPOS wp;
198 ULONG parentHeight = 0;
199 HWND hParent = NULLHANDLE, hFrame = NULLHANDLE;
200 LONG yDelta = pswp->cy - pswpo->cy;
201 ULONG classStyle;
202
203 dprintf(("OS2: WM_WINDOWPOSCHANGED %x %x (%d,%d) (%d,%d)", hwnd, pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
204
205 if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0) break;
206
207 if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
208 if (win32wnd->isChild())
209 hParent = win32wnd->getParent()->getOS2WindowHandle();
210 else
211 hFrame = win32wnd->getOS2FrameWindowHandle();
212 }
213 OSLibMapSWPtoWINDOWPOS(pswp, &wp, pswpo, hParent, hFrame);
214
215 win32wnd->setWindowRect(wp.x, wp.y, wp.x + wp.cx, wp.y + wp.cy);
216 win32wnd->setClientRect(pswpo->x, pswpo->y, pswpo->x + pswpo->cx, pswpo->y + pswpo->cy);
217
218 wp.hwnd = win32wnd->getWindowHandle();
219 if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
220 {
221 Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
222 wp.hwndInsertAfter = wndAfter->getWindowHandle();
223 }
224 classStyle = win32wnd->getClass()->getStyle();
225 if ((yDelta != 0) && ((classStyle & CS_VREDRAW_W) ||
226 ((classStyle & CS_HREDRAW_W) && (pswp->cx != pswpo->cx))))
227 {
228 HENUM henum = WinBeginEnumWindows(pswp->hwnd);
229 SWP swp[10];
230 int i = 0;
231 HWND hwnd;
232
233 while ((hwnd = WinGetNextWindow(henum)) != NULLHANDLE)
234 {
235#if 0
236 if (mdiClient )
237 {
238 continue;
239 }
240#endif
241 WinQueryWindowPos(hwnd, &(swp[i]));
242 swp[i].y += yDelta;
243
244 if (i == 9)
245 {
246 WinSetMultWindowPos(GetThreadHAB(), swp, 10);
247 i = 0;
248 }
249 else
250 {
251 i++;
252 }
253 }
254
255 WinEndEnumWindows(henum);
256
257 if (i)
258 WinSetMultWindowPos(GetThreadHAB(), swp, i);
259 }
260 win32wnd->MsgPosChanged((LPARAM)&wp);
261
262 break;
263 }
264
265 case WM_ERASEBACKGROUND:
266 {
267 if (!win32wnd->isSupressErase()) {
268 BOOL erased = sendEraseBkgnd (win32wnd);
269 win32wnd->setEraseBkgnd (!erased, !erased);
270 }
271 break;
272 }
273 case WM_SIZE:
274 {
275 break;
276 }
277
278 case WM_ACTIVATE:
279 {
280 HWND hwndActivate = (HWND)mp1;
281
282 dprintf(("OS2: WM_ACTIVATE %x", hwnd));
283 if(WinQueryWindowULong(hwndActivate, OFFSET_WIN32PM_MAGIC) != WIN32PM_MAGIC) {
284 //another (non-win32) application's window
285 //set to NULL (allowed according to win32 SDK) to avoid problems
286 hwndActivate = NULL;
287 }
288 if(win32wnd->MsgActivate(1, hwndActivate)) {
289 goto RunDefWndProc;
290 }
291 break;
292 }
293 case WM_FOCUSCHANGE:
294 dprintf(("OS2: WM_FOCUSCHANGE %x", hwnd));
295 goto RunDefWndProc;
296
297 case WM_SETFOCUS:
298 {
299 HWND hwndFocus = (HWND)mp1;
300
301 dprintf(("OS2: WM_SETFOCUS %x %d", hwnd, mp2));
302 if(WinQueryWindowULong(hwndFocus, OFFSET_WIN32PM_MAGIC) != WIN32PM_MAGIC) {
303 //another (non-win32) application's window
304 //set to NULL (allowed according to win32 SDK) to avoid problems
305 hwndFocus = NULL;
306 }
307 if((ULONG)mp2 == TRUE) {
308 rc = win32wnd->MsgSetFocus(hwndFocus);
309 }
310 else rc = win32wnd->MsgKillFocus(hwndFocus);
311 if(rc) {
312 goto RunDefWndProc;
313 }
314 break;
315 }
316 //**************************************************************************
317 //Mouse messages (OS/2 Window coordinates -> Win32 coordinates relative to screen
318 //**************************************************************************
319 case WM_BUTTON1DOWN:
320 dprintf(("OS2: WM_BUTTON1DOWN %x", hwnd));
321 point.x = (*(POINTS *)&mp1).x;
322 point.y = (*(POINTS *)&mp1).y;
323 ClientPoint.x = point.x;
324 ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
325 MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
326 if(win32wnd->MsgButton(BUTTON_LEFTDOWN, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
327 goto RunDefWndProc;
328 }
329 break;
330
331 case WM_BUTTON1UP:
332 dprintf(("OS2: WM_BUTTON1UP %x", hwnd));
333 point.x = (*(POINTS *)&mp1).x;
334 point.y = (*(POINTS *)&mp1).y;
335 ClientPoint.x = point.x;
336 ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
337 MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
338 if(win32wnd->MsgButton(BUTTON_LEFTUP, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
339 goto RunDefWndProc;
340 }
341 break;
342 case WM_BUTTON1DBLCLK:
343 point.x = (*(POINTS *)&mp1).x;
344 point.y = (*(POINTS *)&mp1).y;
345 ClientPoint.x = point.x;
346 ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
347 MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
348 if(win32wnd->MsgButton(BUTTON_LEFTDBLCLICK, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
349 goto RunDefWndProc;
350 }
351 break;
352 case WM_BUTTON2DOWN:
353 point.x = (*(POINTS *)&mp1).x;
354 point.y = (*(POINTS *)&mp1).y;
355 ClientPoint.x = point.x;
356 ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
357 MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
358 if(win32wnd->MsgButton(BUTTON_RIGHTDOWN, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
359 goto RunDefWndProc;
360 }
361 break;
362 case WM_BUTTON2UP:
363 point.x = (*(POINTS *)&mp1).x;
364 point.y = (*(POINTS *)&mp1).y;
365 ClientPoint.x = point.x;
366 ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
367 MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
368 if(win32wnd->MsgButton(BUTTON_RIGHTUP, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
369 goto RunDefWndProc;
370 }
371 break;
372 case WM_BUTTON2DBLCLK:
373 point.x = (*(POINTS *)&mp1).x;
374 point.y = (*(POINTS *)&mp1).y;
375 ClientPoint.x = point.x;
376 ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
377 MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
378 if(win32wnd->MsgButton(BUTTON_RIGHTDBLCLICK, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
379 goto RunDefWndProc;
380 }
381 break;
382 case WM_BUTTON3DOWN:
383 point.x = (*(POINTS *)&mp1).x;
384 point.y = (*(POINTS *)&mp1).y;
385 ClientPoint.x = point.x;
386 ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
387 MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
388 if(win32wnd->MsgButton(BUTTON_MIDDLEDOWN, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
389 goto RunDefWndProc;
390 }
391 break;
392 case WM_BUTTON3UP:
393 point.x = (*(POINTS *)&mp1).x;
394 point.y = (*(POINTS *)&mp1).y;
395 ClientPoint.x = point.x;
396 ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
397 MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
398 if(win32wnd->MsgButton(BUTTON_MIDDLEUP, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
399 goto RunDefWndProc;
400 }
401 break;
402 case WM_BUTTON3DBLCLK:
403 point.x = (*(POINTS *)&mp1).x;
404 point.y = (*(POINTS *)&mp1).y;
405 ClientPoint.x = point.x;
406 ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
407 MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
408 if(win32wnd->MsgButton(BUTTON_MIDDLEDBLCLICK, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
409 goto RunDefWndProc;
410 }
411 break;
412
413 case WM_BUTTON2MOTIONSTART:
414 case WM_BUTTON2MOTIONEND:
415 case WM_BUTTON2CLICK:
416 case WM_BUTTON1MOTIONSTART:
417 case WM_BUTTON1MOTIONEND:
418 case WM_BUTTON1CLICK:
419 case WM_BUTTON3MOTIONSTART:
420 case WM_BUTTON3MOTIONEND:
421 case WM_BUTTON3CLICK:
422 goto RunDefWndProc;
423
424 case WM_MOUSEMOVE:
425 {
426 //Only send this message when the mouse isn't captured
427 if(WinQueryCapture(HWND_DESKTOP) != NULLHANDLE) {
428 goto RunDefWndProc;
429 }
430 ULONG keystate = 0;
431 if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON1))
432 keystate |= WMMOVE_LBUTTON;
433 if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON2))
434 keystate |= WMMOVE_MBUTTON;
435 if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON3))
436 keystate |= WMMOVE_RBUTTON;
437 if(WinGetKeyState(HWND_DESKTOP, VK_SHIFT))
438 keystate |= WMMOVE_SHIFT;
439 if(WinGetKeyState(HWND_DESKTOP, VK_CTRL))
440 keystate |= WMMOVE_CTRL;
441
442 //OS/2 Window coordinates -> Win32 Window coordinates
443 //TODO: What do windows apps that handle this messages return?
444 if(!win32wnd->MsgMouseMove(keystate, SHORT1FROMMP(mp1), MapOS2ToWin32Y(win32wnd, SHORT2FROMMP(mp1)))) {
445 goto RunDefWndProc;
446 }
447 break;
448 }
449
450 //**************************************************************************
451 //Slider messages
452 //**************************************************************************
453 case WM_VSCROLL:
454 case WM_HSCROLL:
455
456 case WM_CONTROL:
457
458 case WM_COMMAND:
459 if(SHORT1FROMMP(mp2) == CMDSRC_MENU) {
460 win32wnd->MsgCommand(CMD_MENU, SHORT1FROMMP(mp1), 0);
461 }
462 if(SHORT1FROMMP(mp2) == CMDSRC_ACCELERATOR) {
463 win32wnd->MsgCommand(CMD_ACCELERATOR, SHORT1FROMMP(mp1), 0);
464 }
465 //todo controls + accelerators
466 break;
467
468 case WM_SYSCOMMAND:
469 {
470 ULONG x = 0, y = 0;
471 ULONG win32sc;
472
473 if(SHORT2FROMMP(mp2) == TRUE) {//syscommand caused by mouse action
474 POINTL pointl;
475 WinQueryPointerPos(HWND_DESKTOP, &pointl);
476 x = pointl.x;
477 y = ScreenHeight - y;
478 }
479 switch(SHORT1FROMMP(mp1)) {
480 case SC_MOVE:
481 win32sc = WIN32SC_MOVE;
482 break;
483 case SC_CLOSE:
484 win32sc = WIN32SC_CLOSE;
485 break;
486 case SC_MAXIMIZE:
487 win32sc = WIN32SC_MAXIMIZE;
488 break;
489 case SC_MINIMIZE:
490 win32sc = WIN32SC_MINIMIZE;
491 break;
492 case SC_NEXTFRAME:
493 case SC_NEXTWINDOW:
494 win32sc = WIN32SC_NEXTWINDOW;
495 break;
496 case SC_RESTORE:
497 win32sc = WIN32SC_RESTORE;
498 break;
499 case SC_TASKMANAGER:
500 win32sc = WIN32SC_TASKLIST;
501 break;
502 default:
503 goto RunDefWndProc;
504 }
505 dprintf(("WM_SYSCOMMAND %x %x (%d,%d)", hwnd, win32sc, x, y));
506 if(win32wnd->MsgSysCommand(win32sc, x, y)) {
507 goto RunDefWndProc;
508 }
509 break;
510 }
511 case WM_CHAR:
512 {
513 ULONG repeatCount=0, virtualKey=0, keyFlags=0, scanCode=0;
514 ULONG flags = SHORT1FROMMP(mp1);
515 BOOL keyWasPressed;
516 char c;
517 USHORT virtualKeyTable [66] = {
518 0x00, // OS/2 VK Win32 VK, Entry 0 is not used
519 0x01, // VK_BUTTON1 VK_LBUTTON
520 0x02, // VK_BUTTON2 VK_RBUTTON
521 0x04, // VK_BUTTON3 VK_MBUTTON
522 0x03, // VK_BREAK VK_CANCEL
523 0x08, // VK_BACKSPACE VK_BACK
524 0x09, // VK_TAB VK_TAB
525 0x00, // VK_BACKTAB No equivalent!
526 0x0D, // VK_NEWLINE VK_RETURN
527 0x10, // VK_SHIFT VK_SHIFT
528 0x11, // VK_CTRL VK_CONTROL
529 0x12, // VK_ALT VK_MENU, best match I guess
530 0x12, // VK_ALTGRAF VK_MENU, best match I guess
531 0x13, // VK_PAUSE VK_PAUSE
532 0x14, // VK_CAPSLOCK VK_CAPITAL
533 0x1B, // VK_ESC VK_ESCAPE
534 0x20, // VK_SPACE VK_SPACE
535 0x00, // VK_PAGEUP No equivalent! At least, I think
536 0x00, // VK_PAGEDOWN No equivalent! At least, I think
537 0x23, // VK_END VK_END
538 0x24, // VK_HOME VK_HOME
539 0x25, // VK_LEFT VK_LEFT
540 0x26, // VK_UP VK_UP
541 0x27, // VK_RIGHT VK_RIGHT
542 0x28, // VK_DOWN VK_DOWN
543 0x2C, // VK_PRINTSCRN VK_SNAPSHOT
544 0x2D, // VK_INSERT VK_INSERT
545 0x2E, // VK_DELETE VK_DELETE
546 0x91, // VK_SCRLLOCK VK_SCROLL
547 0x90, // VK_NUMLOCK VK_NUMLOCK
548 0x2B, // VK_ENTER VK_EXECUTE, best match I guess
549 0x00, // VK_SYSRQ No equivalent!
550 0x70, // VK_F1 VK_F1
551 0x71, // VK_F2 VK_F2
552 0x72, // VK_F3 VK_F3
553 0x73, // VK_F4 VK_F4
554 0x74, // VK_F5 VK_F5
555 0x75, // VK_F6 VK_F6
556 0x76, // VK_F7 VK_F7
557 0x77, // VK_F8 VK_F8
558 0x78, // VK_F9 VK_F9
559 0x79, // VK_F10 VK_F10
560 0x7A, // VK_F11 VK_F11
561 0x7B, // VK_F12 VK_F12
562 0x7C, // VK_F13 VK_F13
563 0x7D, // VK_F14 VK_F14
564 0x7E, // VK_F15 VK_F15
565 0x7F, // VK_F16 VK_F16
566 0x80, // VK_F17 VK_F17
567 0x81, // VK_F18 VK_F18
568 0x82, // VK_F19 VK_F19
569 0x83, // VK_F20 VK_F20
570 0x84, // VK_F21 VK_F21
571 0x85, // VK_F22 VK_F22
572 0x86, // VK_F23 VK_F23
573 0x87, // VK_F24 VK_F24
574 0x00, // VK_ENDDRAG No equivalent!
575 0x0C, // VK_CLEAR VK_CLEAR
576 0xF9, // VK_EREOF VK_EREOF
577 0xFD, // VK_PA1 VK_PA1
578 0xF6, // VK_ATTN VK_ATTN
579 0xF7, // VK_CRSEL VK_CRSEL
580 0xF8, // VK_EXSEL VK_EXSEL
581 0x00, // VK_COPY No equivalent!
582 0x00, // VK_BLK1 No equivalent!
583 0x00}; // VK_BLK2 No equivalent!
584
585
586 repeatCount = SHORT2FROMMP (mp1) >> 8;
587 scanCode = SHORT2FROMMP (mp1) & 255;
588 keyWasPressed = ((SHORT1FROMMP (mp1) & KC_PREVDOWN) == KC_PREVDOWN);
589
590 // both WM_KEYUP & WM_KEYDOWN want a virtual key, find the right Win32 virtual key
591 // given the OS/2 virtual key and OS/2 character
592
593 if (((SHORT1FROMMP (mp1) & KC_CHAR) == KC_CHAR) ||
594 ((SHORT1FROMMP (mp1) & KC_LONEKEY) == KC_LONEKEY))
595 {
596 c = SHORT1FROMMP (mp2);
597 if ((c >= 'A') && (c <= 'Z')) {
598 virtualKey = c;
599 goto VirtualKeyFound;
600 }
601 if ((c >='a') && (c <= 'z')) {
602 virtualKey = c - 32; // make it uppercase
603 goto VirtualKeyFound;
604 }
605 if ((c >= '0') && (c <= '9')) {
606 virtualKey = c;
607 goto VirtualKeyFound;
608 }
609 }
610
611 // convert OS/2 virtual keys to Win32 virtual key
612 if (SHORT2FROMMP (mp2) <= VK_BLK2)
613 virtualKey = virtualKeyTable [SHORT2FROMMP (mp2)];
614
615VirtualKeyFound:
616
617 if ((WinGetKeyState (HWND_DESKTOP, VK_ALT) & 0x8000) == 0)
618 {
619 //
620 // the Alt key is not pressed
621 //
622 if ((flags & KC_KEYUP) == KC_KEYUP) {
623 // send WM_KEYUP message
624
625 if(win32wnd->MsgKeyUp (repeatCount, scanCode, virtualKey)) {
626 goto RunDefWndProc;
627 }
628 }
629 else {
630 // send WM_KEYDOWN message
631 if (win32wnd->MsgKeyDown (repeatCount, scanCode, virtualKey, keyWasPressed))
632 goto RunDefWndProc;
633 }
634 }
635 else {
636 //
637 // the Alt key is pressed
638 //
639 if ((flags & KC_KEYUP) == KC_KEYUP) {
640 // send WM_SYSKEYUP message
641
642 if(win32wnd->MsgSysKeyUp (repeatCount, scanCode, virtualKey)) {
643 goto RunDefWndProc;
644 }
645 }
646 else {
647 // send WM_SYSKEYDOWN message
648 if (win32wnd->MsgSysKeyDown (repeatCount, scanCode, virtualKey, keyWasPressed))
649 goto RunDefWndProc;
650 }
651 }
652
653 break;
654 }
655#if 0
656 case WM_CHAR:
657 {
658 ULONG keyflags = 0, vkey = 0;
659 ULONG fl = SHORT1FROMMP(mp1);
660
661 if(!(fl & KC_CHAR)) {
662// dprintf(("WM_CHAR: no valid character code"));
663 goto RunDefWndProc;
664 }
665 if(fl & KC_VIRTUALKEY) {
666 vkey = SHORT2FROMMP(mp2);
667 }
668 if(fl & KC_KEYUP) {
669 keyflags |= KEY_UP;
670 }
671 if(fl & KC_ALT) {
672 keyflags |= KEY_ALTDOWN;
673 }
674 if(fl & KC_PREVDOWN) {
675 keyflags |= KEY_PREVDOWN;
676 }
677 if(fl & KC_DEADKEY) {
678 keyflags |= KEY_DEADKEY;
679 }
680 if(win32wnd->MsgChar(SHORT1FROMMP(mp2), CHAR3FROMMP(mp1), CHAR4FROMMP(mp1), vkey, keyflags)) {
681 goto RunDefWndProc;
682 }
683 break;
684 }
685#endif
686 case WM_INITMENU:
687 case WM_MENUSELECT:
688 case WM_MENUEND:
689 case WM_NEXTMENU:
690
691 case WM_TIMER:
692 win32wnd->MsgTimer((ULONG)mp1);
693 goto RunDefWndProc;
694
695 case WM_SETWINDOWPARAMS:
696 {
697 WNDPARAMS *wndParams = (WNDPARAMS *)mp1;
698
699 dprintf(("OS2: WM_SETWINDOWPARAMS %x", hwnd));
700 if(wndParams->fsStatus & WPM_TEXT) {
701 if(win32wnd->MsgSetText(wndParams->pszText, wndParams->cchText)) {
702 goto RunDefWndProc;
703 }
704 }
705 goto RunDefWndProc;
706 }
707
708 case WM_QUERYWINDOWPARAMS:
709 {
710 PWNDPARAMS wndpars = (PWNDPARAMS)mp1;
711 ULONG textlen;
712 PSZ wintext;
713
714 if(wndpars->fsStatus & (WPM_CCHTEXT | WPM_TEXT)) {
715 if(wndpars->fsStatus & WPM_CCHTEXT)
716 wndpars->cchText = win32wnd->MsgGetTextLength();
717 if(wndpars->fsStatus & WPM_TEXT)
718 wndpars->pszText = win32wnd->MsgGetText();
719 return (MRESULT)TRUE;
720 }
721 goto RunDefWndProc;
722 }
723
724 case WM_PAINT:
725 dprintf(("OS2: WM_PAINT %x", hwnd));
726
727 if (WinQueryUpdateRect (hwnd, NULL)) {
728 if (!win32wnd->isSupressErase()) {
729 BOOL erased = sendEraseBkgnd (win32wnd);
730 win32wnd->setEraseBkgnd (!erased, !erased);
731 }
732 }
733 win32wnd->setSupressErase (FALSE);
734
735 if(win32wnd->MsgPaint(0, 0)) {
736 goto RunDefWndProc;
737 }
738 break;
739
740 case WM_HITTEST:
741 // Only send this message if the window is enabled
742 if (WinIsWindowEnabled(hwnd))
743 {
744 if(win32wnd->MsgHitTest((*(POINTS *)&mp1).x, MapOS2ToWin32Y(OSLIB_HWND_DESKTOP, hwnd, (*(POINTS *)&mp1).y))) {
745 goto RunDefWndProc;
746 }
747 }
748 else goto RunDefWndProc;
749 break;
750
751 case WM_SYSCOLORCHANGE:
752 case WM_SYSVALUECHANGED:
753 case WM_CALCVALIDRECTS:
754 case WM_SETSELECTION:
755 case WM_PPAINT:
756 case WM_PSETFOCUS:
757 case WM_PSYSCOLORCHANGE:
758 case WM_PSIZE:
759 case WM_PACTIVATE:
760 case WM_PCONTROL:
761 case WM_HELP:
762 case WM_APPTERMINATENOTIFY:
763 case WM_PRESPARAMCHANGED:
764 case WM_DRAWITEM:
765 case WM_MEASUREITEM:
766 case WM_CONTROLPOINTER:
767 case WM_QUERYDLGCODE:
768 case WM_SUBSTITUTESTRING:
769 case WM_MATCHMNEMONIC:
770 case WM_SAVEAPPLICATION:
771 case WM_SEMANTICEVENT:
772 default:
773// dprintf(("OS2: RunDefWndProc msg %x for %x", msg, hwnd));
774 RestoreOS2TIB();
775 return WinDefWindowProc( hwnd, msg, mp1, mp2 );
776 }
777 RestoreOS2TIB();
778 return (MRESULT)FALSE;
779
780RunDefWndProc:
781// dprintf(("OS2: RunDefWndProc msg %x for %x", msg, hwnd));
782 RestoreOS2TIB();
783 return WinDefWindowProc( hwnd, msg, mp1, mp2 );
784} /* End of Win32WindowProc */
785//******************************************************************************
786//******************************************************************************
Note: See TracBrowser for help on using the repository browser.