source: trunk/src/user32/oslibmsgtranslate.cpp@ 2250

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

PostMessage memory leak fixed

File size: 23.4 KB
Line 
1/* $Id: oslibmsgtranslate.cpp,v 1.5 1999-12-29 14:37:16 sandervl Exp $ */
2/*
3 * Window message translation functions for OS/2
4 *
5 *
6 * Copyright 1998-1999 Sander van Leeuwen (sandervl@xs4all.nl)
7 * Copyright 1999 Daniela Engert (dani@ngrt.de)
8 * Copyright 1999 Rene Pronk (R.Pronk@twi.tudelft.nl)
9 *
10 * Project Odin Software License can be found in LICENSE.TXT
11 *
12 * TODO: Extra msgs: which messages must be put into the queue and which can be sent directly?
13 * (According to the docs TranslateMessage really inserts a msg in the queue)
14 * TODO: Filter translation isn't correct for posted messages
15 *
16 */
17#define INCL_WIN
18#define INCL_PM
19#define INCL_DOSPROCESS
20#include <os2.h>
21#include <os2wrap.h>
22#include <string.h>
23#include <misc.h>
24#include "oslibmsg.h"
25#include <win32wnd.h>
26#include "oslibutil.h"
27#include "timer.h"
28#include <thread.h>
29#include <wprocess.h>
30#include "pmwindow.h"
31#include "oslibwin.h"
32
33//Used for key translation while processing WM_CHAR message
34USHORT virtualKeyTable [66] = {
35 0x00, // OS/2 VK Win32 VK, Entry 0 is not used
36 0x01, // VK_BUTTON1 VK_LBUTTON
37 0x02, // VK_BUTTON2 VK_RBUTTON
38 0x04, // VK_BUTTON3 VK_MBUTTON
39 0x03, // VK_BREAK VK_CANCEL
40 0x08, // VK_BACKSPACE VK_BACK
41 0x09, // VK_TAB VK_TAB
42 0x00, // VK_BACKTAB No equivalent!
43 0x0A, // VK_NEWLINE 0x0A (no VK_* def)
44 0x10, // VK_SHIFT VK_SHIFT
45 0x11, // VK_CTRL VK_CONTROL
46 0x12, // VK_ALT VK_MENU, best match I guess
47 0x12, // VK_ALTGRAF VK_MENU, best match I guess
48 0x13, // VK_PAUSE VK_PAUSE
49 0x14, // VK_CAPSLOCK VK_CAPITAL
50 0x1B, // VK_ESC VK_ESCAPE
51 0x20, // VK_SPACE VK_SPACE
52 0x21, // VK_PAGEUP VK_PRIOR
53 0x22, // VK_PAGEDOWN VK_NEXT
54 0x23, // VK_END VK_END
55 0x24, // VK_HOME VK_HOME
56 0x25, // VK_LEFT VK_LEFT
57 0x26, // VK_UP VK_UP
58 0x27, // VK_RIGHT VK_RIGHT
59 0x28, // VK_DOWN VK_DOWN
60 0x2C, // VK_PRINTSCRN VK_SNAPSHOT
61 0x2D, // VK_INSERT VK_INSERT
62 0x2E, // VK_DELETE VK_DELETE
63 0x91, // VK_SCRLLOCK VK_SCROLL
64 0x90, // VK_NUMLOCK VK_NUMLOCK
65 0x0D, // VK_ENTER VK_RETURN
66 0x00, // VK_SYSRQ No equivalent!
67 0x70, // VK_F1 VK_F1
68 0x71, // VK_F2 VK_F2
69 0x72, // VK_F3 VK_F3
70 0x73, // VK_F4 VK_F4
71 0x74, // VK_F5 VK_F5
72 0x75, // VK_F6 VK_F6
73 0x76, // VK_F7 VK_F7
74 0x77, // VK_F8 VK_F8
75 0x78, // VK_F9 VK_F9
76 0x79, // VK_F10 VK_F10
77 0x7A, // VK_F11 VK_F11
78 0x7B, // VK_F12 VK_F12
79 0x7C, // VK_F13 VK_F13
80 0x7D, // VK_F14 VK_F14
81 0x7E, // VK_F15 VK_F15
82 0x7F, // VK_F16 VK_F16
83 0x80, // VK_F17 VK_F17
84 0x81, // VK_F18 VK_F18
85 0x82, // VK_F19 VK_F19
86 0x83, // VK_F20 VK_F20
87 0x84, // VK_F21 VK_F21
88 0x85, // VK_F22 VK_F22
89 0x86, // VK_F23 VK_F23
90 0x87, // VK_F24 VK_F24
91 0x00, // VK_ENDDRAG No equivalent!
92 0x0C, // VK_CLEAR VK_CLEAR
93 0xF9, // VK_EREOF VK_EREOF
94 0xFD, // VK_PA1 VK_PA1
95 0xF6, // VK_ATTN VK_ATTN
96 0xF7, // VK_CRSEL VK_CRSEL
97 0xF8, // VK_EXSEL VK_EXSEL
98 0x00, // VK_COPY No equivalent!
99 0x00, // VK_BLK1 No equivalent!
100 0x00}; // VK_BLK2 No equivalent!
101
102//******************************************************************************
103//******************************************************************************
104BOOL OS2ToWinMsgTranslate(void *pThdb, QMSG *os2Msg, MSG *winMsg, BOOL isUnicode, BOOL fMsgRemoved)
105{
106 Win32BaseWindow *win32wnd = 0;
107 OSLIBPOINT point, ClientPoint;
108 POSTMSG_PACKET *packet;
109 THDB *thdb = (THDB *)pThdb;
110 int i;
111
112 memset(winMsg, 0, sizeof(MSG));
113 win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(os2Msg->hwnd);
114 //PostThreadMessage posts WIN32APP_POSTMSG msg without window handle
115 if((win32wnd == 0 && os2Msg->msg != WM_CREATE && os2Msg->msg != WIN32APP_POSTMSG))
116 {
117 goto dummymessage; //not a win32 client window
118 }
119 winMsg->time = os2Msg->time;
120 winMsg->pt.x = os2Msg->ptl.x;
121 winMsg->pt.y = ScreenHeight - os2Msg->ptl.y - 1;
122 if(win32wnd) //==0 for WM_CREATE
123 winMsg->hwnd = win32wnd->getWindowHandle();
124
125 switch(os2Msg->msg)
126 {
127 case WIN32APP_POSTMSG:
128 {
129 packet = (POSTMSG_PACKET *)os2Msg->mp2;
130 if(packet && ((ULONG)os2Msg->mp1 == WIN32MSG_MAGICA || (ULONG)os2Msg->mp1 == WIN32MSG_MAGICW)) {
131 winMsg->message = packet->Msg;
132 winMsg->wParam = packet->wParam;
133 winMsg->lParam = packet->lParam;
134 if(fMsgRemoved == MSG_REMOVE) free(packet); //free the shared memory here
135 break;
136 }
137 goto dummymessage;
138 }
139
140 //OS/2 msgs
141 case WM_CREATE:
142 {
143 if(thdb->newWindow == 0) {
144 DebugInt3();
145 goto dummymessage;
146 }
147
148 win32wnd = (Win32BaseWindow *)thdb->newWindow;
149
150 winMsg->message = WINWM_CREATE;
151 winMsg->hwnd = win32wnd->getWindowHandle();
152 winMsg->wParam = 0;
153 winMsg->lParam = (LPARAM)win32wnd->tmpcs;
154 break;
155 }
156
157 case WM_QUIT:
158 winMsg->message = WINWM_QUIT;
159 break;
160
161 case WM_CLOSE:
162 winMsg->message = WINWM_CLOSE;
163 break;
164
165 case WM_DESTROY:
166 winMsg->message = WINWM_DESTROY;
167 break;
168
169 case WM_ENABLE:
170 winMsg->message = WINWM_ENABLE;
171 winMsg->wParam = SHORT1FROMMP(os2Msg->mp1);
172 break;
173
174 case WM_SHOW:
175 winMsg->message = WINWM_SHOWWINDOW;
176 winMsg->wParam = SHORT1FROMMP(os2Msg->mp1);
177 break;
178
179 case WM_WINDOWPOSCHANGED:
180 {
181 PSWP pswp = (PSWP)os2Msg->mp1;
182 SWP swpOld = *(pswp + 1);
183 HWND hParent = NULLHANDLE;
184 LONG yDelta = pswp->cy - swpOld.cy;
185 LONG xDelta = pswp->cx - swpOld.cx;
186
187 dprintf(("OS2: WM_WINDOWPOSCHANGED %x %x (%d,%d) (%d,%d)", win32wnd->getWindowHandle(), pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
188
189 if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0) goto dummymessage;
190
191 if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
192 if (win32wnd->isChild()) {
193 if(win32wnd->getParent()) {
194 hParent = win32wnd->getParent()->getOS2WindowHandle();
195 }
196 else goto dummymessage; //parent has just been destroyed
197 }
198 }
199 OSLibMapSWPtoWINDOWPOS(pswp, &thdb->wp, &swpOld, hParent, win32wnd->getOS2FrameWindowHandle());
200
201 if (!win32wnd->CanReceiveSizeMsgs()) goto dummymessage;
202
203 dprintf(("Set client rectangle to (%d,%d)(%d,%d)", swpOld.x, swpOld.y, swpOld.x + swpOld.cx, swpOld.y + swpOld.cy));
204 win32wnd->setClientRect(swpOld.x, swpOld.y, swpOld.x + swpOld.cx, swpOld.y + swpOld.cy);
205
206 thdb->wp.hwnd = win32wnd->getWindowHandle();
207 if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
208 {
209 Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
210 thdb->wp.hwndInsertAfter = wndAfter->getWindowHandle();
211 }
212
213 PRECT lpRect = win32wnd->getWindowRect();
214 //SvL: Only send it when the client has changed & the frame hasn't
215 // If the frame size/position has changed, pmframe.cpp will send
216 // this message
217 if(lpRect->right == thdb->wp.x+thdb->wp.cx && lpRect->bottom == thdb->wp.y+thdb->wp.cy) {
218 winMsg->message = WINWM_WINDOWPOSCHANGED;
219 winMsg->lParam = (LPARAM)&thdb->wp;
220 }
221 else {
222 win32wnd->setWindowRect(thdb->wp.x, thdb->wp.y, thdb->wp.x+thdb->wp.cx, thdb->wp.y+thdb->wp.cy);
223 goto dummymessage;
224 }
225 }
226
227 case WM_ACTIVATE:
228 {
229 HWND hwndActivate = (HWND)os2Msg->mp2;
230 BOOL fMinimized = FALSE;
231
232 if(WinQueryWindowULong(hwndActivate, OFFSET_WIN32PM_MAGIC) != WIN32PM_MAGIC) {
233 //another (non-win32) application's window
234 //set to NULL (allowed according to win32 SDK) to avoid problems
235 hwndActivate = NULL;
236 }
237 else hwndActivate = Win32BaseWindow::OS2ToWin32Handle(hwndActivate);
238
239 if(WinQueryWindowULong(os2Msg->hwnd, QWL_STYLE) & WS_MINIMIZED)
240 {
241 fMinimized = TRUE;
242 }
243
244 winMsg->message = WINWM_ACTIVATE;
245 winMsg->wParam = MAKELONG((SHORT1FROMMP(os2Msg->mp1)) ? WA_ACTIVE_W : WA_INACTIVE_W, fMinimized);
246 winMsg->lParam = (LPARAM)hwndActivate;
247 break;
248 }
249
250 case WM_SETFOCUS:
251 {
252 HWND hwndFocus = (HWND)os2Msg->mp1;
253
254 if(WinQueryWindowULong(hwndFocus, OFFSET_WIN32PM_MAGIC) != WIN32PM_MAGIC) {
255 //another (non-win32) application's window
256 //set to NULL (allowed according to win32 SDK) to avoid problems
257 hwndFocus = NULL;
258 }
259 else hwndFocus = Win32BaseWindow::OS2ToWin32Handle(hwndFocus);
260
261 if((ULONG)os2Msg->mp2 == TRUE) {
262 winMsg->message = WINWM_SETFOCUS;
263 winMsg->wParam = (WPARAM)hwndFocus;
264 }
265 else {
266 winMsg->message = WINWM_KILLFOCUS;
267 winMsg->wParam = (WPARAM)hwndFocus;
268 }
269 break;
270 }
271
272 //**************************************************************************
273 //Mouse messages (OS/2 Window coordinates -> Win32 coordinates relative to screen
274 //**************************************************************************
275 case WM_BUTTON1DOWN:
276 case WM_BUTTON1UP:
277 case WM_BUTTON1DBLCLK:
278 case WM_BUTTON2DOWN:
279 case WM_BUTTON2UP:
280 case WM_BUTTON2DBLCLK:
281 case WM_BUTTON3DOWN:
282 case WM_BUTTON3UP:
283 case WM_BUTTON3DBLCLK:
284 //WM_NC*BUTTON* is posted when the cursor is in a non-client area of the window
285 if(win32wnd->lastHitTestVal != HTCLIENT_W) {
286 winMsg->message = WINWM_NCLBUTTONDOWN + (os2Msg->msg - WM_BUTTON1DOWN);
287 winMsg->wParam = win32wnd->lastHitTestVal;
288 winMsg->lParam = MAKELONG(winMsg->pt.x, winMsg->pt.y); //screen coordinates
289 }
290 else {
291 point.x = (*(POINTS *)&os2Msg->mp1).x;
292 point.y = (*(POINTS *)&os2Msg->mp1).y;
293 ClientPoint.x = point.x;
294 ClientPoint.y = MapOS2ToWin32Y(os2Msg->hwnd, 1, point.y);
295
296 winMsg->message = WINWM_LBUTTONDOWN + (os2Msg->msg - WM_BUTTON1DOWN);
297 winMsg->lParam = MAKELONG(ClientPoint.x, ClientPoint.y); //client coordinates
298 }
299
300 break;
301
302 case WM_BUTTON2MOTIONSTART:
303 case WM_BUTTON2MOTIONEND:
304 case WM_BUTTON2CLICK:
305 case WM_BUTTON1MOTIONSTART:
306 case WM_BUTTON1MOTIONEND:
307 case WM_BUTTON1CLICK:
308 case WM_BUTTON3MOTIONSTART:
309 case WM_BUTTON3MOTIONEND:
310 case WM_BUTTON3CLICK:
311 goto dummymessage;
312
313 case WM_MOUSEMOVE:
314 {
315 ULONG keystate = 0, setcursormsg = WINWM_MOUSEMOVE;
316
317 if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON1) & 0x8000)
318 keystate |= MK_LBUTTON_W;
319 if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON2) & 0x8000)
320 keystate |= MK_RBUTTON_W;
321 if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON3) & 0x8000)
322 keystate |= MK_MBUTTON_W;
323 if(WinGetKeyState(HWND_DESKTOP, VK_SHIFT) & 0x8000)
324 keystate |= MK_SHIFT_W;
325 if(WinGetKeyState(HWND_DESKTOP, VK_CTRL) & 0x8000)
326 keystate |= MK_CONTROL_W;
327
328 //WM_NCMOUSEMOVE is posted when the cursor moves into a non-client area of the window
329 if(win32wnd->lastHitTestVal != HTCLIENT_W)
330 {
331 setcursormsg = WINWM_NCMOUSEMOVE;
332 winMsg->wParam = (WPARAM)win32wnd->lastHitTestVal;
333 winMsg->lParam = MAKELONG(winMsg->pt.x,winMsg->pt.y);
334 } else
335 {
336 winMsg->wParam = (WPARAM)keystate;
337 winMsg->lParam = MAKELONG(SHORT1FROMMP(os2Msg->mp1), MapOS2ToWin32Y(win32wnd, SHORT2FROMMP(os2Msg->mp1)));
338 }
339 //OS/2 Window coordinates -> Win32 Window coordinates
340 winMsg->message = setcursormsg;
341 break;
342 }
343
344 case WM_CONTROL:
345 goto dummymessage;
346
347 case WM_COMMAND:
348 if(SHORT1FROMMP(os2Msg->mp2) == CMDSRC_MENU) {
349 winMsg->message = WINWM_COMMAND;
350 winMsg->wParam = (WPARAM)SHORT1FROMMP(os2Msg->mp1); //id
351 break;
352 }
353 //todo controls
354 goto dummymessage;
355
356 case WM_SYSCOMMAND:
357 {
358 ULONG x = 0, y = 0;
359 ULONG win32sc;
360
361 if(SHORT2FROMMP(os2Msg->mp2) == TRUE) {//syscommand caused by mouse action
362 POINTL pointl;
363 WinQueryPointerPos(HWND_DESKTOP, &pointl);
364 x = pointl.x;
365 y = ScreenHeight - y;
366 }
367 switch(SHORT1FROMMP(os2Msg->mp1)) {
368 case SC_MOVE:
369 win32sc = SC_MOVE_W;
370 break;
371 case SC_CLOSE:
372 win32sc = SC_CLOSE_W;
373 break;
374 case SC_MAXIMIZE:
375 win32sc = SC_MAXIMIZE_W;
376 break;
377 case SC_MINIMIZE:
378 win32sc = SC_MINIMIZE_W;
379 break;
380 case SC_NEXTFRAME:
381 case SC_NEXTWINDOW:
382 win32sc = SC_NEXTWINDOW_W;
383 break;
384 case SC_RESTORE:
385 win32sc = SC_RESTORE_W;
386 break;
387 case SC_TASKMANAGER:
388 win32sc = SC_TASKLIST_W;
389 break;
390 default:
391 goto dummymessage;
392 }
393 winMsg->message = WINWM_SYSCOMMAND;
394 winMsg->wParam = (WPARAM)win32sc;
395 winMsg->lParam = MAKELONG((USHORT)x, (USHORT)y);
396 break;
397 }
398 case WM_CHAR:
399 {
400 ULONG repeatCount=0, virtualKey=0, keyFlags=0, scanCode=0;
401 ULONG flags = SHORT1FROMMP(os2Msg->mp1);
402 BOOL keyWasPressed;
403 char c;
404
405 thdb->fTranslated = FALSE;
406 repeatCount = CHAR3FROMMP(os2Msg->mp1);
407 scanCode = CHAR4FROMMP(os2Msg->mp1);
408 keyWasPressed = ((SHORT1FROMMP (os2Msg->mp1) & KC_PREVDOWN) == KC_PREVDOWN);
409
410 dprintf(("PM: WM_CHAR: %x %x %d %x", SHORT1FROMMP(os2Msg->mp2), SHORT2FROMMP(os2Msg->mp2), repeatCount, scanCode));
411 dprintf(("PM: WM_CHAR: %x", flags));
412
413 // vitali add begin
414 if ( ( SHORT1FROMMP(os2Msg->mp2) & 0x0FF ) == 0x0E0 )
415 {
416 // an extended key ( arrows, ins, del and so on )
417 // get "virtual" scancode from character code cause
418 // for "regular" keys they are equal
419 scanCode = ( SHORT1FROMMP(os2Msg->mp2) >> 8) & 0x0FF;
420 }
421 // vitali add end
422
423 // both WM_KEYUP & WM_KEYDOWN want a virtual key, find the right Win32 virtual key
424 // given the OS/2 virtual key and OS/2 character
425
426 //if (((SHORT1FROMMP (mp1) & KC_CHAR) == KC_CHAR) ||
427 // ((SHORT1FROMMP (mp1) & KC_LONEKEY) == KC_LONEKEY))
428 c = 0;
429 if ((SHORT1FROMMP (os2Msg->mp1) & 0xFF) != 0)
430 {
431 c = SHORT1FROMMP (os2Msg->mp2);
432 if ((c >= 'A') && (c <= 'Z')) {
433 virtualKey = c;
434 goto VirtualKeyFound;
435 }
436 if ((c >='a') && (c <= 'z')) {
437 virtualKey = c - 32; // make it uppercase
438 goto VirtualKeyFound;
439 }
440 if ((c >= '0') && (c <= '9')) {
441 virtualKey = c;
442 goto VirtualKeyFound;
443 }
444 }
445
446 // convert OS/2 virtual keys to Win32 virtual key
447 if (SHORT2FROMMP (os2Msg->mp2) <= VK_BLK2)
448 virtualKey = virtualKeyTable [SHORT2FROMMP (os2Msg->mp2)];
449
450VirtualKeyFound:
451 dprintf (("VIRTUALKEYFOUND:(%x)", virtualKey));
452
453 winMsg->wParam = virtualKey;
454 winMsg->lParam = repeatCount & 0x0FFFF; // bit 0-15, repeatcount
455 winMsg->lParam |= (scanCode & 0x0FF) << 16; // bit 16-23, scancode
456 win32wnd->setExtendedKey(virtualKey, (ULONG *)&winMsg->lParam);
457
458 if(!(SHORT1FROMMP(os2Msg->mp1) & KC_ALT))
459 {
460 //
461 // the Alt key is not pressed
462 //
463 if ((flags & KC_KEYUP) == KC_KEYUP) {
464 // send WM_KEYUP message
465
466 winMsg->message = WINWM_KEYUP;
467 winMsg->lParam |= 1 << 30; // bit 30, previous state, always 1 for a WM_KEYUP message
468 winMsg->lParam |= 1 << 31; // bit 31, transition state, always 1 for WM_KEYUP
469 }
470 else {
471 // send WM_KEYDOWN message
472 winMsg->message = WINWM_KEYDOWN;
473 if (keyWasPressed)
474 winMsg->lParam |= 1 << 30; // bit 30, previous state, 1 means key was pressed
475 }
476 }
477 else {
478 //
479 // the Alt key is pressed
480 //
481 if ((flags & KC_KEYUP) == KC_KEYUP) {
482 // send WM_SYSKEYUP message
483
484 winMsg->message = WINWM_SYSKEYUP;
485 winMsg->lParam |= 1 << 30; // bit 30, previous state, always 1 for a WM_KEYUP message
486 winMsg->lParam |= 1 << 31; // bit 31, transition state, always 1 for WM_KEYUP
487 }
488 else {
489 // send WM_SYSKEYDOWN message
490 winMsg->message = WINWM_SYSKEYDOWN;
491 if (keyWasPressed)
492 winMsg->lParam |= 1 << 30; // bit 30, previous state, 1 means key was pressed
493 }
494 }
495
496 break;
497 }
498
499 case WM_INITMENU:
500 winMsg->message = WINWM_INITMENU;
501 winMsg->wParam = (WPARAM)os2Msg->mp2; //hMenu
502 break;
503
504 case WM_MENUSELECT:
505 case WM_MENUEND:
506 case WM_NEXTMENU:
507 goto dummymessage;
508
509 case WM_TIMER:
510 if (os2Msg->mp2)
511 {
512 BOOL sys;
513 ULONG id;
514
515 if (TIMER_GetTimerInfo(os2Msg->hwnd,(ULONG)os2Msg->mp1,&sys,&id))
516 {
517 winMsg->wParam = (WPARAM)id;
518 winMsg->message= (sys) ? WINWM_SYSTIMER : WINWM_TIMER;
519 break;
520 }
521 }
522 goto dummymessage; //for caret blinking
523
524 case WM_SETWINDOWPARAMS:
525 {
526 WNDPARAMS *wndParams = (WNDPARAMS *)os2Msg->mp1;
527
528 if(wndParams->fsStatus & WPM_TEXT) {
529 win32wnd->MsgSetText(wndParams->pszText, wndParams->cchText);
530 break;
531 }
532 goto dummymessage;
533 }
534
535#if 0
536 case WM_QUERYWINDOWPARAMS:
537 {
538 PWNDPARAMS wndpars = (PWNDPARAMS)mp1;
539 ULONG textlen;
540 PSZ wintext;
541
542 if(wndpars->fsStatus & (WPM_CCHTEXT | WPM_TEXT))
543 {
544 if(wndpars->fsStatus & WPM_CCHTEXT)
545 wndpars->cchText = win32wnd->MsgGetTextLength();
546 if(wndpars->fsStatus & WPM_TEXT)
547 wndpars->pszText = win32wnd->MsgGetText();
548
549 wndpars->fsStatus = 0;
550 wndpars->cbCtlData = 0;
551 wndpars->cbPresParams = 0;
552 goto dummymessage;
553 }
554 }
555#endif
556
557 case WM_PAINT:
558 {
559 if(win32wnd->IsIconic()) {
560 winMsg->message = WINWM_PAINTICON;
561 }
562 else winMsg->message = WINWM_PAINT;
563 break;
564 }
565
566 case WM_HITTEST:
567 {
568 OSLIBPOINT pt;
569
570 pt.x = (*(POINTS *)&os2Msg->mp1).x;
571 pt.y = (*(POINTS *)&os2Msg->mp1).y;
572
573 MapOS2ToWin32Point(OSLIB_HWND_DESKTOP,os2Msg->hwnd,&pt);
574 winMsg->message = WINWM_NCHITTEST;
575 winMsg->wParam = 0;
576 winMsg->lParam = MAKELONG((USHORT)pt.x, (USHORT)pt.y);
577 break;
578 }
579
580 case WM_CONTEXTMENU:
581 {
582 POINTL pt;
583
584 pt.x = (*(POINTS *)&os2Msg->mp1).x;
585 pt.y = (*(POINTS *)&os2Msg->mp1).y;
586 WinMapWindowPoints(os2Msg->hwnd,HWND_DESKTOP,&pt,1);
587 pt.y = WinQuerySysValue(HWND_DESKTOP,SV_CYSCREEN) - pt.y -1;
588 winMsg->message = WINWM_CONTEXTMENU;
589 winMsg->wParam = (WPARAM)win32wnd->getWindowHandle();
590 winMsg->lParam = MAKELONG((USHORT)pt.x, (USHORT)pt.y);
591 break;
592 }
593
594 case WM_SYSCOLORCHANGE:
595 case WM_SYSVALUECHANGED:
596 case WM_SETSELECTION:
597 case WM_PPAINT:
598 case WM_PSETFOCUS:
599 case WM_PSYSCOLORCHANGE:
600 case WM_PSIZE:
601 case WM_PACTIVATE:
602 case WM_PCONTROL:
603 case WM_HELP:
604 case WM_APPTERMINATENOTIFY:
605 case WM_PRESPARAMCHANGED:
606 case WM_DRAWITEM:
607 case WM_MEASUREITEM:
608 case WM_CONTROLPOINTER:
609 case WM_QUERYDLGCODE:
610 case WM_SUBSTITUTESTRING:
611 case WM_MATCHMNEMONIC:
612 case WM_SAVEAPPLICATION:
613 case WM_SEMANTICEVENT:
614 default:
615dummymessage:
616 return FALSE;
617 }
618 return TRUE;
619}
620//******************************************************************************
621//******************************************************************************
622BOOL OSLibWinTranslateMessage(MSG *msg)
623{
624 THDB *thdb;
625
626 thdb = GetThreadTHDB();
627 if(!thdb) {
628 return FALSE;
629 }
630 //NOTE: These actually need to be posted so that the next message retrieved by GetMessage contains
631 // the newly generated WM_CHAR message.
632 if(!thdb->fTranslated && MsgThreadPtr->msg == WM_CHAR && !((SHORT1FROMMP(MsgThreadPtr->mp1) & KC_KEYUP) == KC_KEYUP))
633 {//TranslatedMessage was called before DispatchMessage, so queue WM_CHAR message
634 ULONG fl = SHORT1FROMMP(MsgThreadPtr->mp1);
635 MSG extramsg;
636
637 memcpy(&extramsg, msg, sizeof(MSG));
638 extramsg.wParam = SHORT1FROMMP(MsgThreadPtr->mp2);
639 extramsg.lParam = 0;
640
641 if(!(fl & KC_CHAR)) {
642 return FALSE;
643 }
644
645 if(fl & KC_VIRTUALKEY) {
646 if(msg->wParam)
647 extramsg.wParam = msg->wParam;
648 else extramsg.wParam = SHORT2FROMMP(MsgThreadPtr->mp2);
649 }
650
651 if(msg->message >= WINWM_SYSKEYDOWN) {
652 extramsg.message = WINWM_SYSCHAR;
653 }
654 else extramsg.message = WINWM_CHAR;
655
656 if(fl & KC_DEADKEY) {
657 extramsg.message++; //WM_DEADCHAR/WM_SYSDEADCHAR
658 }
659
660 extramsg.lParam = msg->lParam & 0x00FFFFFF;
661 if(fl & KC_ALT)
662 extramsg.lParam |= (1<<29);
663 if(fl & KC_PREVDOWN)
664 extramsg.lParam |= (1<<30);
665 if(fl & KC_KEYUP)
666 extramsg.lParam |= (1<<31);
667
668 thdb->fTranslated = TRUE;
669 memcpy(&thdb->msgWCHAR, &extramsg, sizeof(MSG));
670 return TRUE;
671 }
672 return FALSE;
673}
674//******************************************************************************
675//******************************************************************************
676
Note: See TracBrowser for help on using the repository browser.