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

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

SetWindowRgn memory leak + InsertMenu bug fixed

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