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

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

get/peekmessage fixes, timer fix, (user/new) replaced wm_hittest code; added wm_ncactivate, changed system menu

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