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

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

System menu commands now work

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