source: trunk/src/user32/new/oslibmsgtranslate.cpp@ 2377

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

* empty log message *

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