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

Last change on this file since 2204 was 2204, checked in by cbratschi, 26 years ago

non-client fixes, DefWndProc enhancements, several other bugs fixed

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