source: trunk/src/user32/oslibmsg.cpp@ 7370

Last change on this file since 7370 was 7370, checked in by phaller, 24 years ago

ugly AltGr hack

File size: 21.4 KB
Line 
1/* $Id: oslibmsg.cpp,v 1.50 2001-11-16 17:47:05 phaller Exp $ */
2/*
3 * Window message translation functions for OS/2
4 *
5 *
6 * Copyright 1999 Sander van Leeuwen (sandervl@xs4all.nl)
7 *
8 *
9 * Project Odin Software License can be found in LICENSE.TXT
10 *
11 * TODO: Some messages that are sent to the frame window are directly passed on to the client
12 * -> Get/PeekMessage never gets them as we return a dummy message for non-client windows
13 * (i.e. menu WM_COMMAND messages)
14 *
15 * TODO: Filter translation isn't correct! (for posted messages or messages that don't have
16 * a PM version.
17 *
18 */
19#define INCL_WIN
20#define INCL_PM
21#define INCL_DOSPROCESS
22#include <os2wrap.h>
23#include <odinwrap.h>
24#include <string.h>
25#include <misc.h>
26#include "oslibmsg.h"
27#include <winconst.h>
28#include <win32api.h>
29#include <winuser32.h>
30#include "oslibutil.h"
31#include "timer.h"
32#include <thread.h>
33#include <wprocess.h>
34#include "pmwindow.h"
35#include "oslibwin.h"
36#include <win\hook.h>
37#include <winscan.h>
38#include <winkeyboard.h>
39
40#define DBG_LOCALLOG DBG_oslibmsg
41#include "dbglocal.h"
42
43
44ODINDEBUGCHANNEL(USER32-OSLIBMSG)
45
46
47
48typedef BOOL (EXPENTRY FNTRANS)(MSG *, QMSG *);
49typedef FNTRANS *PFNTRANS;
50
51typedef struct
52{
53 ULONG msgOS2;
54 ULONG msgWin32;
55// PFNTRANS toOS2;
56// PFNTRANS toWIN32;
57} MSGTRANSTAB, *PMSGTRANSTAB;
58
59//NOTE: Must be ordered by win32 message id!!
60MSGTRANSTAB MsgTransTab[] = {
61 WM_NULL, WINWM_NULL,
62 WM_CREATE, WINWM_CREATE,
63 WM_DESTROY, WINWM_DESTROY,
64 WM_MOVE, WINWM_MOVE, //TODO: Sent directly
65 WM_SIZE, WINWM_SIZE, //TODO: Sent directly
66 WM_ACTIVATE, WINWM_ACTIVATE,
67 WM_SETFOCUS, WINWM_SETFOCUS,
68 WM_SETFOCUS, WINWM_KILLFOCUS,
69 WM_ENABLE, WINWM_ENABLE,
70 WM_PAINT, WINWM_PAINT,
71 WM_CLOSE, WINWM_CLOSE,
72 WM_QUIT, WINWM_QUIT,
73 WM_SHOW, WINWM_SHOWWINDOW,
74
75 WM_HITTEST, WINWM_NCHITTEST,
76
77 //todo: not always right if mouse msg turns out to be for the client window
78 WM_MOUSEMOVE, WINWM_NCMOUSEMOVE,
79 WM_BUTTON1DOWN, WINWM_NCLBUTTONDOWN,
80 WM_BUTTON1UP, WINWM_NCLBUTTONUP,
81 WM_BUTTON1DBLCLK, WINWM_NCLBUTTONDBLCLK,
82 WM_BUTTON2DOWN, WINWM_NCRBUTTONDOWN,
83 WM_BUTTON2UP, WINWM_NCRBUTTONUP,
84 WM_BUTTON2DBLCLK, WINWM_NCRBUTTONDBLCLK,
85 WM_BUTTON3DOWN, WINWM_NCMBUTTONDOWN,
86 WM_BUTTON3UP, WINWM_NCMBUTTONUP,
87 WM_BUTTON3DBLCLK, WINWM_NCMBUTTONDBLCLK,
88
89 //TODO: Needs better translation!
90 WM_CHAR, WINWM_KEYDOWN, //WM_KEYFIRST
91 WM_CHAR, WINWM_KEYUP,
92 WM_CHAR, WINWM_CHAR,
93 WM_CHAR, WINWM_DEADCHAR,
94 WM_CHAR, WINWM_SYSKEYDOWN,
95 WM_CHAR, WINWM_SYSKEYUP,
96 WM_CHAR, WINWM_SYSCHAR,
97 WM_CHAR, WINWM_SYSDEADCHAR,
98 WM_CHAR, WINWM_KEYLAST,
99
100 //
101 WM_TIMER, WINWM_TIMER,
102
103 //
104 //todo: not always right if mouse msg turns out to be for the nonclient window
105 WM_MOUSEMOVE, WINWM_MOUSEMOVE, //WM_MOUSEFIRST
106 WM_BUTTON1DOWN, WINWM_LBUTTONDOWN,
107 WM_BUTTON1UP, WINWM_LBUTTONUP,
108 WM_BUTTON1DBLCLK, WINWM_LBUTTONDBLCLK,
109 WM_BUTTON2DOWN, WINWM_RBUTTONDOWN,
110 WM_BUTTON2UP, WINWM_RBUTTONUP,
111 WM_BUTTON2DBLCLK, WINWM_RBUTTONDBLCLK,
112 WM_BUTTON3DOWN, WINWM_MBUTTONDOWN,
113 WM_BUTTON3UP, WINWM_MBUTTONUP,
114 WM_BUTTON3DBLCLK, WINWM_MBUTTONDBLCLK,
115 WM_BUTTON3DBLCLK, WINWM_MOUSEWHEEL, //WM_MOUSELAST
116 999999999, 999999999,
117};
118#define MAX_MSGTRANSTAB (sizeof(MsgTransTab)/sizeof(MsgTransTab[0]))
119
120//******************************************************************************
121//******************************************************************************
122void WinToOS2MsgTranslate(MSG *winMsg, QMSG *os2Msg, BOOL isUnicode)
123{
124 dprintf(("WinToOS2MsgTranslate not implemented"));
125// memcpy(os2Msg, winMsg, sizeof(MSG));
126// os2Msg->hwnd = Win32ToOS2Handle(winMsg->hwnd);
127// os2Msg->reserved = 0;
128}
129//******************************************************************************
130//TODO: NOT COMPLETE nor 100% CORRECT!!!
131//If both the minimum & maximum message are unknown, the result can be wrong (max > min)!
132//******************************************************************************
133ULONG TranslateWinMsg(ULONG msg, BOOL fMinFilter)
134{
135 if(msg == 0)
136 return 0;
137
138 if(msg >= WINWM_USER)
139 return msg + WIN32APP_POSTMSG;
140
141 for(int i=0;i<MAX_MSGTRANSTAB;i++)
142 {
143 if(fMinFilter && MsgTransTab[i].msgWin32 >= msg) {
144 return MsgTransTab[i].msgOS2;
145 }
146 else
147 if(!fMinFilter && MsgTransTab[i].msgWin32 >= msg) {
148 if(MsgTransTab[i].msgWin32 == msg)
149 return MsgTransTab[i].msgOS2;
150 else return MsgTransTab[i-1].msgOS2;
151 }
152 }
153
154 //not found, get everything
155 dprintf(("WARNING: TranslateWinMsg: message %x not found", msg));
156 return 0;
157}
158//******************************************************************************
159//******************************************************************************
160void OSLibWinPostQuitMessage(ULONG nExitCode)
161{
162 APIRET rc;
163
164 rc = WinPostQueueMsg(NULLHANDLE, WM_QUIT, MPFROMLONG(nExitCode), 0);
165 dprintf(("WinPostQueueMsg %d returned %d", nExitCode, rc));
166}
167//******************************************************************************
168//******************************************************************************
169LONG OSLibWinDispatchMsg(MSG *msg, BOOL isUnicode)
170{
171 TEB *teb;
172 QMSG os2msg;
173 LONG rc;
174
175 teb = GetThreadTEB();
176 if(teb == NULL) {
177 DebugInt3();
178 return FALSE;
179 }
180
181 //TODO: What to do if app changed msg? (translate)
182 // WinToOS2MsgTranslate(msg, &qmsg, isUnicode);
183
184 if(!memcmp(msg, &teb->o.odin.winmsg, sizeof(MSG)) || msg->hwnd == 0) {
185 memcpy(&os2msg, &teb->o.odin.os2msg, sizeof(QMSG));
186 teb->o.odin.os2msg.time = -1;
187 teb->o.odin.winmsg.time = -1;
188 if(msg->hwnd) {
189 teb->o.odin.nrOfMsgs = 1;
190 teb->o.odin.msgstate++; //odd -> next call to our PM window handler should dispatch the translated msg
191 memcpy(&teb->o.odin.msg, msg, sizeof(MSG));
192 }
193 if(os2msg.hwnd || os2msg.msg == WM_QUIT) {
194 memset(&teb->o.odin.os2msg, 0, sizeof(teb->o.odin.os2msg));
195 memset(&teb->o.odin.winmsg, 0, sizeof(teb->o.odin.winmsg));
196 return (LONG)WinDispatchMsg(teb->o.odin.hab, &os2msg);
197 }
198 //SvL: Don't dispatch messages sent by PostThreadMessage (correct??)
199 // Or WM_TIMER msgs with no window handle or timer proc
200 return 0;
201
202 }
203 else {//is this allowed?
204// dprintf(("WARNING: OSLibWinDispatchMsg: called with own message!"));
205 return SendMessageA(msg->hwnd, msg->message, msg->wParam, msg->lParam);
206 }
207}
208//******************************************************************************
209//******************************************************************************
210
211static void i_MostUglyAltGrHack(LPMSG pMsg)
212{
213 switch (pMsg->message)
214 {
215 case WINWM_KEYUP:
216 case WINWM_SYSKEYUP:
217 USHORT wWinScan = (pMsg->lParam & 0x00ff0000) >> 16;
218 if (wWinScan == WINSCAN_ALTRIGHT)
219 {
220 KeySetOverlayKeyState(VK_RMENU_W, KEYOVERLAYSTATE_DONTCARE);
221 KeySetOverlayKeyState(VK_MENU_W, KEYOVERLAYSTATE_DONTCARE);
222 }
223 break;
224 }
225}
226
227
228BOOL OSLibWinGetMsg(LPMSG pMsg, HWND hwnd, UINT uMsgFilterMin, UINT uMsgFilterMax,
229 BOOL isUnicode)
230{
231 BOOL rc, eaten;
232 TEB *teb;
233 QMSG os2msg;
234 HWND hwndOS2 = 0;
235 ULONG filtermin, filtermax;
236
237 if(hwnd) {
238 hwndOS2 = Win32ToOS2Handle(hwnd);
239 if(hwndOS2 == NULL) {
240 memset(pMsg, 0, sizeof(MSG));
241 dprintf(("GetMsg: window %x NOT FOUND!", hwnd));
242 SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
243 return TRUE;
244 }
245 }
246
247 teb = GetThreadTEB();
248 if(teb == NULL) {
249 DebugInt3();
250 return TRUE;
251 }
252
253 if(teb->o.odin.fTranslated && (!hwnd || hwnd == teb->o.odin.msgWCHAR.hwnd)) {
254 if(uMsgFilterMin) {
255 if(teb->o.odin.msgWCHAR.message < uMsgFilterMin)
256 goto continuegetmsg;
257 }
258 if(uMsgFilterMax) {
259 if(teb->o.odin.msgWCHAR.message > uMsgFilterMax)
260 goto continuegetmsg;
261 }
262 teb->o.odin.fTranslated = FALSE;
263 memcpy(pMsg, &teb->o.odin.msgWCHAR, sizeof(MSG));
264 teb->o.odin.os2msg.msg = 0;
265 teb->o.odin.os2msg.hwnd = 0;
266
267 // @@@PH verify this
268 // if this is a keyup or keydown message, we've got to
269 // call the keyboard hook here
270 // send keyboard messages to the registered hooks
271 switch (pMsg->message)
272 {
273 case WINWM_KEYDOWN:
274 case WINWM_KEYUP:
275 case WINWM_SYSKEYDOWN:
276 case WINWM_SYSKEYUP:
277 // only supposed to be called upon WM_KEYDOWN
278 // and WM_KEYUP according to docs.
279 if(ProcessKbdHook(pMsg, TRUE))
280 goto continuegetmsg;
281 break;
282 }
283
284 i_MostUglyAltGrHack(pMsg);
285
286 return (pMsg->message != WINWM_QUIT);
287 }
288
289continuegetmsg:
290 if(hwnd) {
291 filtermin = TranslateWinMsg(uMsgFilterMin, TRUE);
292 filtermax = TranslateWinMsg(uMsgFilterMax, FALSE);
293 if(filtermin > filtermax) {
294 ULONG tmp = filtermin;
295 filtermin = filtermax;
296 filtermax = filtermin;
297 }
298 do {
299 WinWaitMsg(teb->o.odin.hab, filtermin, filtermax);
300 rc = OSLibWinPeekMsg(pMsg, hwnd, uMsgFilterMin, uMsgFilterMax, PM_REMOVE_W, isUnicode);
301 }
302 while(rc == FALSE);
303
304 return (pMsg->message != WINWM_QUIT);
305 }
306 else
307 {
308 filtermin = TranslateWinMsg(uMsgFilterMin, TRUE);
309 filtermax = TranslateWinMsg(uMsgFilterMax, FALSE);
310 if(filtermin > filtermax) {
311 ULONG tmp = filtermin;
312 filtermin = filtermax;
313 filtermax = filtermin;
314 }
315 do {
316 eaten = FALSE;
317 rc = WinGetMsg(teb->o.odin.hab, &os2msg, 0, filtermin, filtermax);
318 if (os2msg.msg == WM_TIMER)
319 eaten = TIMER_HandleTimer(&os2msg);
320 } while (eaten);
321 }
322 if(OS2ToWinMsgTranslate((PVOID)teb, &os2msg, pMsg, isUnicode, MSG_REMOVE) == FALSE) {
323 //dispatch untranslated message immediately
324 WinDispatchMsg(teb->o.odin.hab, &os2msg);
325 //and get the next one
326 return OSLibWinGetMsg(pMsg, hwnd, uMsgFilterMin, uMsgFilterMax, isUnicode);
327 }
328
329 memcpy(&teb->o.odin.os2msg, &os2msg, sizeof(QMSG));
330 memcpy(&teb->o.odin.winmsg, pMsg, sizeof(MSG));
331
332 // send keyboard messages to the registered hooks
333 switch (pMsg->message)
334 {
335 case WINWM_KEYDOWN:
336 case WINWM_KEYUP:
337 case WINWM_SYSKEYDOWN:
338 case WINWM_SYSKEYUP:
339 // only supposed to be called upon WM_KEYDOWN
340 // and WM_KEYUP according to docs.
341 if(ProcessKbdHook(pMsg, TRUE))
342 goto continuegetmsg;
343 break;
344 }
345
346 i_MostUglyAltGrHack(pMsg);
347
348 return rc;
349}
350
351
352//******************************************************************************
353//PeekMessage retrieves only messages associated with the window identified by the
354//hwnd parameter or any of its children as specified by the IsChild function, and within
355//the range of message values given by the uMsgFilterMin and uMsgFilterMax
356//parameters. If hwnd is NULL, PeekMessage retrieves messages for any window that
357//belongs to the current thread making the call. (PeekMessage does not retrieve
358//messages for windows that belong to other threads.) If hwnd is -1, PeekMessage only
359//returns messages with a hwnd value of NULL, as posted by the PostAppMessage
360//function. If uMsgFilterMin and uMsgFilterMax are both zero, PeekMessage returns all
361//available messages (no range filtering is performed).
362//TODO: Not working as specified right now!
363//******************************************************************************
364BOOL OSLibWinPeekMsg(LPMSG pMsg, HWND hwnd, UINT uMsgFilterMin, UINT uMsgFilterMax,
365 DWORD fRemove, BOOL isUnicode)
366{
367 BOOL rc, eaten;
368 TEB *teb;
369 QMSG os2msg;
370 HWND hwndOS2 = 0;
371
372 if(hwnd && hwnd != -1) {
373 hwndOS2 = Win32ToOS2Handle(hwnd);
374 if(hwndOS2 == NULL) {
375 dprintf(("PeekMsg: window %x NOT FOUND!", hwnd));
376 SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
377 return FALSE;
378 }
379 }
380
381 teb = GetThreadTEB();
382 if(teb == NULL) {
383 DebugInt3();
384 return FALSE;
385 }
386
387 if(teb->o.odin.fTranslated && (!hwnd || hwnd == teb->o.odin.msgWCHAR.hwnd)) {
388 if(uMsgFilterMin) {
389 if(teb->o.odin.msgWCHAR.message < uMsgFilterMin)
390 goto continuepeekmsg;
391 }
392 if(uMsgFilterMax) {
393 if(teb->o.odin.msgWCHAR.message > uMsgFilterMax)
394 goto continuepeekmsg;
395 }
396
397 if(fRemove & PM_REMOVE_W) {
398 teb->o.odin.fTranslated = FALSE;
399 teb->o.odin.os2msg.msg = 0;
400 teb->o.odin.os2msg.hwnd = 0;
401 }
402 memcpy(pMsg, &teb->o.odin.msgWCHAR, sizeof(MSG));
403
404 // @@@PH verify this
405 // if this is a keyup or keydown message, we've got to
406 // call the keyboard hook here
407 // send keyboard messages to the registered hooks
408 switch (pMsg->message)
409 {
410 case WINWM_KEYDOWN:
411 case WINWM_KEYUP:
412 case WINWM_SYSKEYDOWN:
413 case WINWM_SYSKEYUP:
414 // only supposed to be called upon WM_KEYDOWN
415 // and WM_KEYUP according to docs.
416 if(ProcessKbdHook(pMsg, fRemove))
417 goto continuepeekmsg;
418 break;
419 }
420
421 return TRUE;
422 }
423
424continuepeekmsg:
425 do {
426 eaten = FALSE;
427 rc = WinPeekMsg(teb->o.odin.hab, &os2msg, hwndOS2, TranslateWinMsg(uMsgFilterMin, TRUE),
428 TranslateWinMsg(uMsgFilterMax, FALSE), (fRemove & PM_REMOVE_W) ? PM_REMOVE : PM_NOREMOVE);
429
430 if (rc && (fRemove & PM_REMOVE_W) && os2msg.msg == WM_TIMER) {
431 eaten = TIMER_HandleTimer(&os2msg);
432 }
433 }
434 while (eaten && rc);
435
436 if(rc == FALSE) {
437 return FALSE;
438 }
439
440 // @@@PH
441 // warning - OS2ToWinMsgTranslate might insert additional messages
442 // into the queue
443 if(OS2ToWinMsgTranslate((PVOID)teb, &os2msg, pMsg, isUnicode, (fRemove & PM_REMOVE_W) ? MSG_REMOVE : MSG_NOREMOVE) == FALSE)
444 {
445 //unused PM message; dispatch immediately and grab next one
446 dprintf2(("OSLibWinPeekMsg: Untranslated message; dispatched immediately"));
447 if(!(fRemove & PM_REMOVE_W)) {
448 rc = WinPeekMsg(teb->o.odin.hab, &os2msg, hwndOS2, TranslateWinMsg(uMsgFilterMin, TRUE),
449 TranslateWinMsg(uMsgFilterMax, FALSE), PM_REMOVE);
450 }
451 WinDispatchMsg(teb->o.odin.hab, &os2msg);
452 return OSLibWinPeekMsg(pMsg, hwnd, uMsgFilterMin, uMsgFilterMax,
453 fRemove, isUnicode);
454 }
455 //TODO: This is not safe! There's no guarantee this message will be dispatched and it might overwrite a previous message
456 if(fRemove & PM_REMOVE_W) {
457 memcpy(&teb->o.odin.os2msg, &os2msg, sizeof(QMSG));
458 memcpy(&teb->o.odin.winmsg, pMsg, sizeof(MSG));
459 }
460
461 // send keyboard messages to the registered hooks
462 switch (pMsg->message)
463 {
464 case WINWM_KEYDOWN:
465 case WINWM_KEYUP:
466 case WINWM_SYSKEYDOWN:
467 case WINWM_SYSKEYUP:
468 // only supposed to be called upon WM_KEYDOWN
469 // and WM_KEYUP according to docs.
470 if(ProcessKbdHook(pMsg, fRemove))
471 goto continuepeekmsg;
472 break;
473 }
474
475 return rc;
476}
477//******************************************************************************
478//******************************************************************************
479ULONG OSLibWinQueryMsgTime()
480{
481 return WinQueryMsgTime(GetThreadHAB());
482}
483//******************************************************************************
484//******************************************************************************
485BOOL OSLibWinWaitMessage()
486{
487 return WinWaitMsg(GetThreadHAB(), 0, 0);
488}
489//******************************************************************************
490//TODO: QS_HOTKEY
491//******************************************************************************
492ULONG OSLibWinQueryQueueStatus()
493{
494 ULONG statusOS2, statusWin32 = 0;
495
496 statusOS2 = WinQueryQueueStatus(HWND_DESKTOP);
497
498 if(statusOS2 & QS_KEY)
499 statusWin32 |= QS_KEY_W;
500 if(statusOS2 & QS_MOUSEBUTTON)
501 statusWin32 |= QS_MOUSEBUTTON_W;
502 if(statusOS2 & QS_MOUSEMOVE)
503 statusWin32 |= QS_MOUSEMOVE_W;
504 if(statusOS2 & QS_TIMER)
505 statusWin32 |= QS_TIMER_W;
506 if(statusOS2 & QS_PAINT)
507 statusWin32 |= QS_PAINT_W;
508 if(statusOS2 & QS_POSTMSG)
509 statusWin32 |= QS_POSTMESSAGE_W;
510 if(statusOS2 & QS_SENDMSG)
511 statusWin32 |= QS_SENDMESSAGE_W;
512
513 return statusWin32;
514}
515//******************************************************************************
516//******************************************************************************
517BOOL OSLibWinInSendMessage()
518{
519 return WinInSendMsg(GetThreadHAB());
520}
521//******************************************************************************
522//******************************************************************************
523DWORD OSLibWinGetMessagePos()
524{
525 APIRET rc;
526 POINTL ptl;
527
528 rc = WinQueryMsgPos(GetThreadHAB(), &ptl);
529 if(!rc) {
530 return 0;
531 }
532 //convert to windows coordinates
533 return MAKEULONG(ptl.x,mapScreenY(ptl.y));
534}
535//******************************************************************************
536//******************************************************************************
537LONG OSLibWinGetMessageTime()
538{
539 return (LONG)WinQueryMsgTime(GetThreadHAB());
540}
541//******************************************************************************
542//******************************************************************************
543BOOL OSLibWinReplyMessage(ULONG result)
544{
545 return (BOOL)WinReplyMsg( NULLHANDLE, NULLHANDLE, HMQ_CURRENT, (MRESULT)result);
546}
547//******************************************************************************
548//******************************************************************************
549ULONG OSLibSendMessage(HWND hwnd, ULONG msg, ULONG wParam, ULONG lParam, BOOL fUnicode)
550{
551 POSTMSG_PACKET *packet = (POSTMSG_PACKET *)_smalloc(sizeof(POSTMSG_PACKET));
552
553 if(NULL == packet)
554 {
555 dprintf(("user32::oslibmsg::OSLibSendMessage - allocated packet structure is NULL, heapmin=%d\n",
556 _sheapmin() ));
557
558 // PH: we cannot provide a correct returncode :(
559 DebugInt3();
560 return 0;
561 }
562
563 packet->wParam = wParam;
564 packet->lParam = lParam;
565
566 return (ULONG)WinSendMsg(hwnd, WIN32APP_POSTMSG+msg, (MPARAM)((fUnicode) ? WIN32MSG_MAGICW : WIN32MSG_MAGICA), (MPARAM)packet);
567}
568//******************************************************************************
569//******************************************************************************
570ULONG OSLibWinBroadcastMsg(ULONG msg, ULONG wParam, ULONG lParam, BOOL fSend)
571{
572 return WinBroadcastMsg(HWND_DESKTOP, WIN32APP_POSTMSG+msg, (MPARAM)wParam, (MPARAM)lParam,
573 (fSend) ? BMSG_SEND : BMSG_POST);
574}
575//******************************************************************************
576//******************************************************************************
577BOOL OSLibPostMessage(HWND hwnd, ULONG msg, ULONG wParam, ULONG lParam, BOOL fUnicode)
578{
579 POSTMSG_PACKET *packet = (POSTMSG_PACKET *)_smalloc(sizeof(POSTMSG_PACKET));
580
581 if (NULL == packet)
582 {
583 dprintf(("user32::oslibmsg::OSLibPostMessage - allocated packet structure is NULL, heapmin=%d\n",
584 _sheapmin() ));
585
586 // PH: we can provide a correct returncode
587 DebugInt3();
588 return FALSE;
589 }
590 packet->wParam = wParam;
591 packet->lParam = lParam;
592 return WinPostMsg(hwnd, WIN32APP_POSTMSG+msg, (MPARAM)((fUnicode) ? WIN32MSG_MAGICW : WIN32MSG_MAGICA), (MPARAM)packet);
593}
594//******************************************************************************
595//Direct posting of messages that must remain invisible to the win32 app
596//******************************************************************************
597BOOL OSLibPostMessageDirect(HWND hwnd, ULONG msg, ULONG wParam, ULONG lParam)
598{
599 return WinPostMsg(hwnd, msg, (MPARAM)wParam, (MPARAM)lParam);
600}
601//******************************************************************************
602BOOL _System _O32_PostThreadMessage( DWORD, UINT, WPARAM, LPARAM );
603
604inline BOOL O32_PostThreadMessage(DWORD a, UINT b, WPARAM c, LPARAM d)
605{
606 BOOL yyrc;
607 USHORT sel = RestoreOS2FS();
608
609 yyrc = _O32_PostThreadMessage(a, b, c, d);
610 SetFS(sel);
611
612 return yyrc;
613}
614//******************************************************************************
615BOOL OSLibPostThreadMessage(ULONG threadid, UINT msg, WPARAM wParam, LPARAM lParam, BOOL fUnicode)
616{
617 TEB *teb = GetTEBFromThreadId(threadid);
618 POSTMSG_PACKET *packet = (POSTMSG_PACKET *)_smalloc(sizeof(POSTMSG_PACKET));
619 BOOL ret;
620
621 if(NULL == packet)
622 {
623 dprintf(("user32::oslibmsg::OSLibPostMessage - allocated packet structure is NULL, heapmin=%d\n",
624 _sheapmin() ));
625
626 DebugInt3();
627 // PH: we can provide a correct returncode
628 return FALSE;
629 }
630
631 if(teb == NULL) {
632 dprintf(("OSLibPostThreadMessage: thread %x not found!", threadid));
633 return FALSE;
634 }
635 dprintf(("PostThreadMessageA %x %x %x %x -> hmq %x", threadid, msg, wParam, lParam, teb->o.odin.hmq));
636 packet->wParam = wParam;
637 packet->lParam = lParam;
638
639 ret = WinPostQueueMsg((HMQ)teb->o.odin.hmq, WIN32APP_POSTMSG+msg,
640 (MPARAM)((fUnicode) ? WIN32MSG_MAGICW : WIN32MSG_MAGICA),
641 (MPARAM)packet);
642
643 if(ret == FALSE)
644 {
645 SetLastError(ERROR_INVALID_PARAMETER_W);
646 return FALSE;
647 }
648 SetLastError(ERROR_SUCCESS_W);
649 return TRUE;
650}
651//******************************************************************************
652//******************************************************************************
653
Note: See TracBrowser for help on using the repository browser.