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

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

PostThreadMessage fix

File size: 23.4 KB
Line 
1/* $Id: oslibmsgtranslate.cpp,v 1.4 1999-12-29 12:39:44 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 fTranslateExtraMsgs)
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 == WIN32PM_MAGIC) {
131 winMsg->message = packet->Msg;
132 winMsg->wParam = packet->wParam;
133 winMsg->lParam = packet->lParam;
134 if(win32wnd == NULL) {
135 free(packet); //messages posted by PostThreadMessage are never dispatched, so free the memory here
136 }
137 break;
138 }
139 goto dummymessage;
140 }
141
142 //OS/2 msgs
143 case WM_CREATE:
144 {
145 if(thdb->newWindow == 0) {
146 DebugInt3();
147 goto dummymessage;
148 }
149
150 win32wnd = (Win32BaseWindow *)thdb->newWindow;
151
152 winMsg->message = WINWM_CREATE;
153 winMsg->hwnd = win32wnd->getWindowHandle();
154 winMsg->wParam = 0;
155 winMsg->lParam = (LPARAM)win32wnd->tmpcs;
156 break;
157 }
158
159 case WM_QUIT:
160 winMsg->message = WINWM_QUIT;
161 break;
162
163 case WM_CLOSE:
164 winMsg->message = WINWM_CLOSE;
165 break;
166
167 case WM_DESTROY:
168 winMsg->message = WINWM_DESTROY;
169 break;
170
171 case WM_ENABLE:
172 winMsg->message = WINWM_ENABLE;
173 winMsg->wParam = SHORT1FROMMP(os2Msg->mp1);
174 break;
175
176 case WM_SHOW:
177 winMsg->message = WINWM_SHOWWINDOW;
178 winMsg->wParam = SHORT1FROMMP(os2Msg->mp1);
179 break;
180
181 case WM_WINDOWPOSCHANGED:
182 {
183 PSWP pswp = (PSWP)os2Msg->mp1;
184 SWP swpOld = *(pswp + 1);
185 HWND hParent = NULLHANDLE;
186 LONG yDelta = pswp->cy - swpOld.cy;
187 LONG xDelta = pswp->cx - swpOld.cx;
188
189 dprintf(("OS2: WM_WINDOWPOSCHANGED %x %x (%d,%d) (%d,%d)", win32wnd->getWindowHandle(), pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
190
191 if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0) goto dummymessage;
192
193 if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
194 if (win32wnd->isChild()) {
195 if(win32wnd->getParent()) {
196 hParent = win32wnd->getParent()->getOS2WindowHandle();
197 }
198 else goto dummymessage; //parent has just been destroyed
199 }
200 }
201 OSLibMapSWPtoWINDOWPOS(pswp, &thdb->wp, &swpOld, hParent, win32wnd->getOS2FrameWindowHandle());
202
203 if (!win32wnd->CanReceiveSizeMsgs()) goto dummymessage;
204
205 dprintf(("Set client rectangle to (%d,%d)(%d,%d)", swpOld.x, swpOld.y, swpOld.x + swpOld.cx, swpOld.y + swpOld.cy));
206 win32wnd->setClientRect(swpOld.x, swpOld.y, swpOld.x + swpOld.cx, swpOld.y + swpOld.cy);
207
208 thdb->wp.hwnd = win32wnd->getWindowHandle();
209 if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
210 {
211 Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
212 thdb->wp.hwndInsertAfter = wndAfter->getWindowHandle();
213 }
214
215 PRECT lpRect = win32wnd->getWindowRect();
216 //SvL: Only send it when the client has changed & the frame hasn't
217 // If the frame size/position has changed, pmframe.cpp will send
218 // this message
219 if(lpRect->right == thdb->wp.x+thdb->wp.cx && lpRect->bottom == thdb->wp.y+thdb->wp.cy) {
220 winMsg->message = WINWM_WINDOWPOSCHANGED;
221 winMsg->lParam = (LPARAM)&thdb->wp;
222 }
223 else {
224 win32wnd->setWindowRect(thdb->wp.x, thdb->wp.y, thdb->wp.x+thdb->wp.cx, thdb->wp.y+thdb->wp.cy);
225 goto dummymessage;
226 }
227 }
228
229 case WM_ACTIVATE:
230 {
231 HWND hwndActivate = (HWND)os2Msg->mp2;
232 BOOL fMinimized = FALSE;
233
234 if(WinQueryWindowULong(hwndActivate, OFFSET_WIN32PM_MAGIC) != WIN32PM_MAGIC) {
235 //another (non-win32) application's window
236 //set to NULL (allowed according to win32 SDK) to avoid problems
237 hwndActivate = NULL;
238 }
239 else hwndActivate = Win32BaseWindow::OS2ToWin32Handle(hwndActivate);
240
241 if(WinQueryWindowULong(os2Msg->hwnd, QWL_STYLE) & WS_MINIMIZED)
242 {
243 fMinimized = TRUE;
244 }
245
246 winMsg->message = WINWM_ACTIVATE;
247 winMsg->wParam = MAKELONG((SHORT1FROMMP(os2Msg->mp1)) ? WA_ACTIVE_W : WA_INACTIVE_W, fMinimized);
248 winMsg->lParam = (LPARAM)hwndActivate;
249 break;
250 }
251
252 case WM_SETFOCUS:
253 {
254 HWND hwndFocus = (HWND)os2Msg->mp1;
255
256 if(WinQueryWindowULong(hwndFocus, OFFSET_WIN32PM_MAGIC) != WIN32PM_MAGIC) {
257 //another (non-win32) application's window
258 //set to NULL (allowed according to win32 SDK) to avoid problems
259 hwndFocus = NULL;
260 }
261 else hwndFocus = Win32BaseWindow::OS2ToWin32Handle(hwndFocus);
262
263 if((ULONG)os2Msg->mp2 == TRUE) {
264 winMsg->message = WINWM_SETFOCUS;
265 winMsg->wParam = (WPARAM)hwndFocus;
266 }
267 else {
268 winMsg->message = WINWM_KILLFOCUS;
269 winMsg->wParam = (WPARAM)hwndFocus;
270 }
271 break;
272 }
273
274 //**************************************************************************
275 //Mouse messages (OS/2 Window coordinates -> Win32 coordinates relative to screen
276 //**************************************************************************
277 case WM_BUTTON1DOWN:
278 case WM_BUTTON1UP:
279 case WM_BUTTON1DBLCLK:
280 case WM_BUTTON2DOWN:
281 case WM_BUTTON2UP:
282 case WM_BUTTON2DBLCLK:
283 case WM_BUTTON3DOWN:
284 case WM_BUTTON3UP:
285 case WM_BUTTON3DBLCLK:
286 //WM_NC*BUTTON* is posted when the cursor is in a non-client area of the window
287 if(win32wnd->lastHitTestVal != HTCLIENT_W) {
288 winMsg->message = WINWM_NCLBUTTONDOWN + (os2Msg->msg - WM_BUTTON1DOWN);
289 winMsg->wParam = win32wnd->lastHitTestVal;
290 winMsg->lParam = MAKELONG(winMsg->pt.x, winMsg->pt.y); //screen coordinates
291 }
292 else {
293 point.x = (*(POINTS *)&os2Msg->mp1).x;
294 point.y = (*(POINTS *)&os2Msg->mp1).y;
295 ClientPoint.x = point.x;
296 ClientPoint.y = MapOS2ToWin32Y(os2Msg->hwnd, 1, point.y);
297
298 winMsg->message = WINWM_LBUTTONDOWN + (os2Msg->msg - WM_BUTTON1DOWN);
299 winMsg->lParam = MAKELONG(ClientPoint.x, ClientPoint.y); //client coordinates
300 }
301
302 break;
303
304 case WM_BUTTON2MOTIONSTART:
305 case WM_BUTTON2MOTIONEND:
306 case WM_BUTTON2CLICK:
307 case WM_BUTTON1MOTIONSTART:
308 case WM_BUTTON1MOTIONEND:
309 case WM_BUTTON1CLICK:
310 case WM_BUTTON3MOTIONSTART:
311 case WM_BUTTON3MOTIONEND:
312 case WM_BUTTON3CLICK:
313 goto dummymessage;
314
315 case WM_MOUSEMOVE:
316 {
317 ULONG keystate = 0, setcursormsg = WINWM_MOUSEMOVE;
318
319 if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON1) & 0x8000)
320 keystate |= MK_LBUTTON_W;
321 if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON2) & 0x8000)
322 keystate |= MK_RBUTTON_W;
323 if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON3) & 0x8000)
324 keystate |= MK_MBUTTON_W;
325 if(WinGetKeyState(HWND_DESKTOP, VK_SHIFT) & 0x8000)
326 keystate |= MK_SHIFT_W;
327 if(WinGetKeyState(HWND_DESKTOP, VK_CTRL) & 0x8000)
328 keystate |= MK_CONTROL_W;
329
330 //WM_NCMOUSEMOVE is posted when the cursor moves into a non-client area of the window
331 if(win32wnd->lastHitTestVal != HTCLIENT_W)
332 {
333 setcursormsg = WINWM_NCMOUSEMOVE;
334 winMsg->wParam = (WPARAM)win32wnd->lastHitTestVal;
335 winMsg->lParam = MAKELONG(winMsg->pt.x,winMsg->pt.y);
336 } else
337 {
338 winMsg->wParam = (WPARAM)keystate;
339 winMsg->lParam = MAKELONG(SHORT1FROMMP(os2Msg->mp1), MapOS2ToWin32Y(win32wnd, SHORT2FROMMP(os2Msg->mp1)));
340 }
341 //OS/2 Window coordinates -> Win32 Window coordinates
342 winMsg->message = setcursormsg;
343 break;
344 }
345
346 case WM_CONTROL:
347 goto dummymessage;
348
349 case WM_COMMAND:
350 if(SHORT1FROMMP(os2Msg->mp2) == CMDSRC_MENU) {
351 winMsg->message = WINWM_COMMAND;
352 winMsg->wParam = (WPARAM)SHORT1FROMMP(os2Msg->mp1); //id
353 break;
354 }
355 //todo controls
356 goto dummymessage;
357
358 case WM_SYSCOMMAND:
359 {
360 ULONG x = 0, y = 0;
361 ULONG win32sc;
362
363 if(SHORT2FROMMP(os2Msg->mp2) == TRUE) {//syscommand caused by mouse action
364 POINTL pointl;
365 WinQueryPointerPos(HWND_DESKTOP, &pointl);
366 x = pointl.x;
367 y = ScreenHeight - y;
368 }
369 switch(SHORT1FROMMP(os2Msg->mp1)) {
370 case SC_MOVE:
371 win32sc = SC_MOVE_W;
372 break;
373 case SC_CLOSE:
374 win32sc = SC_CLOSE_W;
375 break;
376 case SC_MAXIMIZE:
377 win32sc = SC_MAXIMIZE_W;
378 break;
379 case SC_MINIMIZE:
380 win32sc = SC_MINIMIZE_W;
381 break;
382 case SC_NEXTFRAME:
383 case SC_NEXTWINDOW:
384 win32sc = SC_NEXTWINDOW_W;
385 break;
386 case SC_RESTORE:
387 win32sc = SC_RESTORE_W;
388 break;
389 case SC_TASKMANAGER:
390 win32sc = SC_TASKLIST_W;
391 break;
392 default:
393 goto dummymessage;
394 }
395 winMsg->message = WINWM_SYSCOMMAND;
396 winMsg->wParam = (WPARAM)win32sc;
397 winMsg->lParam = MAKELONG((USHORT)x, (USHORT)y);
398 break;
399 }
400 case WM_CHAR:
401 {
402 ULONG repeatCount=0, virtualKey=0, keyFlags=0, scanCode=0;
403 ULONG flags = SHORT1FROMMP(os2Msg->mp1);
404 BOOL keyWasPressed;
405 char c;
406
407 thdb->fTranslated = FALSE;
408 repeatCount = CHAR3FROMMP(os2Msg->mp1);
409 scanCode = CHAR4FROMMP(os2Msg->mp1);
410 keyWasPressed = ((SHORT1FROMMP (os2Msg->mp1) & KC_PREVDOWN) == KC_PREVDOWN);
411
412 dprintf(("PM: WM_CHAR: %x %x %d %x", SHORT1FROMMP(os2Msg->mp2), SHORT2FROMMP(os2Msg->mp2), repeatCount, scanCode));
413 dprintf(("PM: WM_CHAR: %x", flags));
414
415 // vitali add begin
416 if ( ( SHORT1FROMMP(os2Msg->mp2) & 0x0FF ) == 0x0E0 )
417 {
418 // an extended key ( arrows, ins, del and so on )
419 // get "virtual" scancode from character code cause
420 // for "regular" keys they are equal
421 scanCode = ( SHORT1FROMMP(os2Msg->mp2) >> 8) & 0x0FF;
422 }
423 // vitali add end
424
425 // both WM_KEYUP & WM_KEYDOWN want a virtual key, find the right Win32 virtual key
426 // given the OS/2 virtual key and OS/2 character
427
428 //if (((SHORT1FROMMP (mp1) & KC_CHAR) == KC_CHAR) ||
429 // ((SHORT1FROMMP (mp1) & KC_LONEKEY) == KC_LONEKEY))
430 c = 0;
431 if ((SHORT1FROMMP (os2Msg->mp1) & 0xFF) != 0)
432 {
433 c = SHORT1FROMMP (os2Msg->mp2);
434 if ((c >= 'A') && (c <= 'Z')) {
435 virtualKey = c;
436 goto VirtualKeyFound;
437 }
438 if ((c >='a') && (c <= 'z')) {
439 virtualKey = c - 32; // make it uppercase
440 goto VirtualKeyFound;
441 }
442 if ((c >= '0') && (c <= '9')) {
443 virtualKey = c;
444 goto VirtualKeyFound;
445 }
446 }
447
448 // convert OS/2 virtual keys to Win32 virtual key
449 if (SHORT2FROMMP (os2Msg->mp2) <= VK_BLK2)
450 virtualKey = virtualKeyTable [SHORT2FROMMP (os2Msg->mp2)];
451
452VirtualKeyFound:
453 dprintf (("VIRTUALKEYFOUND:(%x)", virtualKey));
454
455 winMsg->wParam = virtualKey;
456 winMsg->lParam = repeatCount & 0x0FFFF; // bit 0-15, repeatcount
457 winMsg->lParam |= (scanCode & 0x0FF) << 16; // bit 16-23, scancode
458 win32wnd->setExtendedKey(virtualKey, (ULONG *)&winMsg->lParam);
459
460 if(!(SHORT1FROMMP(os2Msg->mp1) & KC_ALT))
461 {
462 //
463 // the Alt key is not pressed
464 //
465 if ((flags & KC_KEYUP) == KC_KEYUP) {
466 // send WM_KEYUP message
467
468 winMsg->message = WINWM_KEYUP;
469 winMsg->lParam |= 1 << 30; // bit 30, previous state, always 1 for a WM_KEYUP message
470 winMsg->lParam |= 1 << 31; // bit 31, transition state, always 1 for WM_KEYUP
471 }
472 else {
473 // send WM_KEYDOWN message
474 winMsg->message = WINWM_KEYDOWN;
475 if (keyWasPressed)
476 winMsg->lParam |= 1 << 30; // bit 30, previous state, 1 means key was pressed
477 }
478 }
479 else {
480 //
481 // the Alt key is pressed
482 //
483 if ((flags & KC_KEYUP) == KC_KEYUP) {
484 // send WM_SYSKEYUP message
485
486 winMsg->message = WINWM_SYSKEYUP;
487 winMsg->lParam |= 1 << 30; // bit 30, previous state, always 1 for a WM_KEYUP message
488 winMsg->lParam |= 1 << 31; // bit 31, transition state, always 1 for WM_KEYUP
489 }
490 else {
491 // send WM_SYSKEYDOWN message
492 winMsg->message = WINWM_SYSKEYDOWN;
493 if (keyWasPressed)
494 winMsg->lParam |= 1 << 30; // bit 30, previous state, 1 means key was pressed
495 }
496 }
497
498 break;
499 }
500
501 case WM_INITMENU:
502 winMsg->message = WINWM_INITMENU;
503 winMsg->wParam = (WPARAM)os2Msg->mp2; //hMenu
504 break;
505
506 case WM_MENUSELECT:
507 case WM_MENUEND:
508 case WM_NEXTMENU:
509 goto dummymessage;
510
511 case WM_TIMER:
512 if (os2Msg->mp2)
513 {
514 BOOL sys;
515 ULONG id;
516
517 if (TIMER_GetTimerInfo(os2Msg->hwnd,(ULONG)os2Msg->mp1,&sys,&id))
518 {
519 winMsg->wParam = (WPARAM)id;
520 winMsg->message= (sys) ? WINWM_SYSTIMER : WINWM_TIMER;
521 break;
522 }
523 }
524 goto dummymessage; //for caret blinking
525
526 case WM_SETWINDOWPARAMS:
527 {
528 WNDPARAMS *wndParams = (WNDPARAMS *)os2Msg->mp1;
529
530 if(wndParams->fsStatus & WPM_TEXT) {
531 win32wnd->MsgSetText(wndParams->pszText, wndParams->cchText);
532 break;
533 }
534 goto dummymessage;
535 }
536
537#if 0
538 case WM_QUERYWINDOWPARAMS:
539 {
540 PWNDPARAMS wndpars = (PWNDPARAMS)mp1;
541 ULONG textlen;
542 PSZ wintext;
543
544 if(wndpars->fsStatus & (WPM_CCHTEXT | WPM_TEXT))
545 {
546 if(wndpars->fsStatus & WPM_CCHTEXT)
547 wndpars->cchText = win32wnd->MsgGetTextLength();
548 if(wndpars->fsStatus & WPM_TEXT)
549 wndpars->pszText = win32wnd->MsgGetText();
550
551 wndpars->fsStatus = 0;
552 wndpars->cbCtlData = 0;
553 wndpars->cbPresParams = 0;
554 goto dummymessage;
555 }
556 }
557#endif
558
559 case WM_PAINT:
560 {
561 if(win32wnd->IsIconic()) {
562 winMsg->message = WINWM_PAINTICON;
563 }
564 else winMsg->message = WINWM_PAINT;
565 break;
566 }
567
568 case WM_HITTEST:
569 {
570 OSLIBPOINT pt;
571
572 pt.x = (*(POINTS *)&os2Msg->mp1).x;
573 pt.y = (*(POINTS *)&os2Msg->mp1).y;
574
575 MapOS2ToWin32Point(OSLIB_HWND_DESKTOP,os2Msg->hwnd,&pt);
576 winMsg->message = WINWM_NCHITTEST;
577 winMsg->wParam = 0;
578 winMsg->lParam = MAKELONG((USHORT)pt.x, (USHORT)pt.y);
579 break;
580 }
581
582 case WM_CONTEXTMENU:
583 {
584 POINTL pt;
585
586 pt.x = (*(POINTS *)&os2Msg->mp1).x;
587 pt.y = (*(POINTS *)&os2Msg->mp1).y;
588 WinMapWindowPoints(os2Msg->hwnd,HWND_DESKTOP,&pt,1);
589 pt.y = WinQuerySysValue(HWND_DESKTOP,SV_CYSCREEN) - pt.y -1;
590 winMsg->message = WINWM_CONTEXTMENU;
591 winMsg->wParam = (WPARAM)win32wnd->getWindowHandle();
592 winMsg->lParam = MAKELONG((USHORT)pt.x, (USHORT)pt.y);
593 break;
594 }
595
596 case WM_SYSCOLORCHANGE:
597 case WM_SYSVALUECHANGED:
598 case WM_SETSELECTION:
599 case WM_PPAINT:
600 case WM_PSETFOCUS:
601 case WM_PSYSCOLORCHANGE:
602 case WM_PSIZE:
603 case WM_PACTIVATE:
604 case WM_PCONTROL:
605 case WM_HELP:
606 case WM_APPTERMINATENOTIFY:
607 case WM_PRESPARAMCHANGED:
608 case WM_DRAWITEM:
609 case WM_MEASUREITEM:
610 case WM_CONTROLPOINTER:
611 case WM_QUERYDLGCODE:
612 case WM_SUBSTITUTESTRING:
613 case WM_MATCHMNEMONIC:
614 case WM_SAVEAPPLICATION:
615 case WM_SEMANTICEVENT:
616 default:
617dummymessage:
618 return FALSE;
619 }
620 return TRUE;
621}
622//******************************************************************************
623//******************************************************************************
624BOOL OSLibWinTranslateMessage(MSG *msg)
625{
626 THDB *thdb;
627
628 thdb = GetThreadTHDB();
629 if(!thdb) {
630 return FALSE;
631 }
632 //NOTE: These actually need to be posted so that the next message retrieved by GetMessage contains
633 // the newly generated WM_CHAR message.
634 if(!thdb->fTranslated && MsgThreadPtr->msg == WM_CHAR && !((SHORT1FROMMP(MsgThreadPtr->mp1) & KC_KEYUP) == KC_KEYUP))
635 {//TranslatedMessage was called before DispatchMessage, so queue WM_CHAR message
636 ULONG fl = SHORT1FROMMP(MsgThreadPtr->mp1);
637 MSG extramsg;
638
639 memcpy(&extramsg, msg, sizeof(MSG));
640 extramsg.wParam = SHORT1FROMMP(MsgThreadPtr->mp2);
641 extramsg.lParam = 0;
642
643 if(!(fl & KC_CHAR)) {
644 return FALSE;
645 }
646
647 if(fl & KC_VIRTUALKEY) {
648 if(msg->wParam)
649 extramsg.wParam = msg->wParam;
650 else extramsg.wParam = SHORT2FROMMP(MsgThreadPtr->mp2);
651 }
652
653 if(msg->message >= WINWM_SYSKEYDOWN) {
654 extramsg.message = WINWM_SYSCHAR;
655 }
656 else extramsg.message = WINWM_CHAR;
657
658 if(fl & KC_DEADKEY) {
659 extramsg.message++; //WM_DEADCHAR/WM_SYSDEADCHAR
660 }
661
662 extramsg.lParam = msg->lParam & 0x00FFFFFF;
663 if(fl & KC_ALT)
664 extramsg.lParam |= (1<<29);
665 if(fl & KC_PREVDOWN)
666 extramsg.lParam |= (1<<30);
667 if(fl & KC_KEYUP)
668 extramsg.lParam |= (1<<31);
669
670 thdb->fTranslated = TRUE;
671 memcpy(&thdb->msgWCHAR, &extramsg, sizeof(MSG));
672 return TRUE;
673 }
674 return FALSE;
675}
676//******************************************************************************
677//******************************************************************************
678
Note: See TracBrowser for help on using the repository browser.