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

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

scrollbar support and many other things

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