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

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

Message translation bugfixes

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