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

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

.

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