| 1 | /* $Id: oslibmsg.cpp,v 1.9 2000-01-05 21:25:03 cbratschi 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 <os2.h>
|
|---|
| 23 | #include <os2wrap.h>
|
|---|
| 24 | #include <string.h>
|
|---|
| 25 | #include <misc.h>
|
|---|
| 26 | #include "oslibmsg.h"
|
|---|
| 27 | #include <win32wnd.h>
|
|---|
| 28 | #include "oslibutil.h"
|
|---|
| 29 | #include "timer.h"
|
|---|
| 30 | #include <thread.h>
|
|---|
| 31 | #include <wprocess.h>
|
|---|
| 32 | #include "pmwindow.h"
|
|---|
| 33 | #include "oslibwin.h"
|
|---|
| 34 |
|
|---|
| 35 | typedef BOOL (EXPENTRY FNTRANS)(MSG *, QMSG *);
|
|---|
| 36 | typedef FNTRANS *PFNTRANS;
|
|---|
| 37 |
|
|---|
| 38 | typedef struct
|
|---|
| 39 | {
|
|---|
| 40 | ULONG msgOS2;
|
|---|
| 41 | ULONG msgWin32;
|
|---|
| 42 | // PFNTRANS toOS2;
|
|---|
| 43 | // PFNTRANS toWIN32;
|
|---|
| 44 | } MSGTRANSTAB, *PMSGTRANSTAB;
|
|---|
| 45 |
|
|---|
| 46 | //NOTE: Must be ordered by win32 message id!!
|
|---|
| 47 | MSGTRANSTAB MsgTransTab[] = {
|
|---|
| 48 | WM_NULL, WINWM_NULL,
|
|---|
| 49 | WM_CREATE, WINWM_CREATE,
|
|---|
| 50 | WM_DESTROY, WINWM_DESTROY,
|
|---|
| 51 | WM_MOVE, WINWM_MOVE, //TODO: Sent directly
|
|---|
| 52 | WM_SIZE, WINWM_SIZE, //TODO: Sent directly
|
|---|
| 53 | WM_ACTIVATE, WINWM_ACTIVATE,
|
|---|
| 54 | WM_SETFOCUS, WINWM_SETFOCUS,
|
|---|
| 55 | WM_SETFOCUS, WINWM_KILLFOCUS,
|
|---|
| 56 | WM_ENABLE, WINWM_ENABLE,
|
|---|
| 57 | WM_PAINT, WINWM_PAINT,
|
|---|
| 58 | WM_CLOSE, WINWM_CLOSE,
|
|---|
| 59 | WM_QUIT, WINWM_QUIT,
|
|---|
| 60 | WM_SHOW, WINWM_SHOWWINDOW,
|
|---|
| 61 |
|
|---|
| 62 | WM_HITTEST, WINWM_NCHITTEST,
|
|---|
| 63 |
|
|---|
| 64 | //TODO: Needs better translation!
|
|---|
| 65 | WM_CHAR, WINWM_KEYDOWN,
|
|---|
| 66 | WM_CHAR, WINWM_KEYUP,
|
|---|
| 67 | WM_CHAR, WINWM_CHAR,
|
|---|
| 68 | WM_CHAR, WINWM_DEADCHAR,
|
|---|
| 69 | WM_CHAR, WINWM_SYSKEYDOWN,
|
|---|
| 70 | WM_CHAR, WINWM_SYSKEYUP,
|
|---|
| 71 | WM_CHAR, WINWM_SYSCHAR,
|
|---|
| 72 | WM_CHAR, WINWM_SYSDEADCHAR,
|
|---|
| 73 | WM_CHAR, WINWM_KEYLAST,
|
|---|
| 74 |
|
|---|
| 75 | WM_COMMAND, WINWM_COMMAND,
|
|---|
| 76 | WM_SYSCOMMAND, WINWM_SYSCOMMAND,
|
|---|
| 77 | //
|
|---|
| 78 | WM_TIMER, WINWM_TIMER,
|
|---|
| 79 | WM_INITMENU, WINWM_INITMENU,
|
|---|
| 80 | //
|
|---|
| 81 | WM_MOUSEMOVE, WINWM_MOUSEMOVE,
|
|---|
| 82 | WM_BUTTON1DOWN, WINWM_LBUTTONDOWN,
|
|---|
| 83 | WM_BUTTON1UP, WINWM_LBUTTONUP,
|
|---|
| 84 | WM_BUTTON1DBLCLK, WINWM_LBUTTONDBLCLK,
|
|---|
| 85 | WM_BUTTON2DOWN, WINWM_RBUTTONDOWN,
|
|---|
| 86 | WM_BUTTON2UP, WINWM_RBUTTONUP,
|
|---|
| 87 | WM_BUTTON2DBLCLK, WINWM_RBUTTONDBLCLK,
|
|---|
| 88 | WM_BUTTON3DOWN, WINWM_MBUTTONDOWN,
|
|---|
| 89 | WM_BUTTON3UP, WINWM_MBUTTONUP,
|
|---|
| 90 | WM_BUTTON3DBLCLK, WINWM_MBUTTONDBLCLK,
|
|---|
| 91 |
|
|---|
| 92 | 999999999, 999999999,
|
|---|
| 93 | };
|
|---|
| 94 | #define MAX_MSGTRANSTAB (sizeof(MsgTransTab)/sizeof(MsgTransTab[0]))
|
|---|
| 95 |
|
|---|
| 96 | QMSG *MsgThreadPtr = 0;
|
|---|
| 97 |
|
|---|
| 98 | LRESULT WIN32API SendMessageA(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
|---|
| 99 |
|
|---|
| 100 | //******************************************************************************
|
|---|
| 101 | //******************************************************************************
|
|---|
| 102 | BOOL OSLibInitMsgQueue()
|
|---|
| 103 | {
|
|---|
| 104 | if(DosAllocThreadLocalMemory(sizeof(QMSG)/sizeof(ULONG), (PULONG *)&MsgThreadPtr) != 0)
|
|---|
| 105 | {
|
|---|
| 106 | dprintf(("OSLibInitMsgQueue: local thread memory alloc failed!!"));
|
|---|
| 107 | DebugInt3();
|
|---|
| 108 | return FALSE;
|
|---|
| 109 | }
|
|---|
| 110 | return TRUE;
|
|---|
| 111 | }
|
|---|
| 112 | //******************************************************************************
|
|---|
| 113 | //******************************************************************************
|
|---|
| 114 | void WinToOS2MsgTranslate(MSG *winMsg, QMSG *os2Msg, BOOL isUnicode)
|
|---|
| 115 | {
|
|---|
| 116 | // memcpy(os2Msg, winMsg, sizeof(MSG));
|
|---|
| 117 | // os2Msg->hwnd = Win32Window::Win32ToOS2Handle(winMsg->hwnd);
|
|---|
| 118 | // os2Msg->reserved = 0;
|
|---|
| 119 | }
|
|---|
| 120 | //******************************************************************************
|
|---|
| 121 | //TODO: NOT COMPLETE nor 100% CORRECT!!!
|
|---|
| 122 | //If both the minimum & maximum message are unknown, the result can be wrong (max > min)!
|
|---|
| 123 | //******************************************************************************
|
|---|
| 124 | ULONG TranslateWinMsg(ULONG msg, BOOL fMinFilter)
|
|---|
| 125 | {
|
|---|
| 126 | if(msg == 0)
|
|---|
| 127 | return 0;
|
|---|
| 128 |
|
|---|
| 129 | if(msg >= WINWM_USER)
|
|---|
| 130 | return WIN32APP_POSTMSG;
|
|---|
| 131 |
|
|---|
| 132 | for(int i=0;i<MAX_MSGTRANSTAB;i++)
|
|---|
| 133 | {
|
|---|
| 134 | if(fMinFilter && MsgTransTab[i].msgWin32 >= msg) {
|
|---|
| 135 | return MsgTransTab[i].msgOS2;
|
|---|
| 136 | }
|
|---|
| 137 | else
|
|---|
| 138 | if(!fMinFilter && MsgTransTab[i].msgWin32 >= msg) {
|
|---|
| 139 | if(MsgTransTab[i].msgWin32 == msg)
|
|---|
| 140 | return MsgTransTab[i].msgOS2;
|
|---|
| 141 | else return MsgTransTab[i-1].msgOS2;
|
|---|
| 142 | }
|
|---|
| 143 | }
|
|---|
| 144 |
|
|---|
| 145 | return 0;
|
|---|
| 146 | }
|
|---|
| 147 | //******************************************************************************
|
|---|
| 148 | //******************************************************************************
|
|---|
| 149 | void OSLibWinPostQuitMessage(ULONG nExitCode)
|
|---|
| 150 | {
|
|---|
| 151 | APIRET rc;
|
|---|
| 152 |
|
|---|
| 153 | rc = WinPostQueueMsg(NULLHANDLE, WM_QUIT, (MPARAM)nExitCode, 0);
|
|---|
| 154 | dprintf(("WinPostQueueMsg %d returned %d", nExitCode, rc));
|
|---|
| 155 | }
|
|---|
| 156 | //******************************************************************************
|
|---|
| 157 | //******************************************************************************
|
|---|
| 158 | LONG OSLibWinDispatchMsg(MSG *msg, BOOL isUnicode)
|
|---|
| 159 | {
|
|---|
| 160 | THDB *thdb;
|
|---|
| 161 | QMSG os2msg;
|
|---|
| 162 | LONG rc;
|
|---|
| 163 |
|
|---|
| 164 | thdb = GetThreadTHDB();
|
|---|
| 165 | if(thdb == NULL) {
|
|---|
| 166 | DebugInt3();
|
|---|
| 167 | return FALSE;
|
|---|
| 168 | }
|
|---|
| 169 |
|
|---|
| 170 | //TODO: What to do if app changed msg? (translate)
|
|---|
| 171 | // WinToOS2MsgTranslate(msg, &qmsg, isUnicode);
|
|---|
| 172 |
|
|---|
| 173 | if(msg->time == MsgThreadPtr->time || msg->hwnd == 0) {
|
|---|
| 174 | memcpy(&os2msg, MsgThreadPtr, sizeof(QMSG));
|
|---|
| 175 | MsgThreadPtr->time = -1;
|
|---|
| 176 | if(msg->hwnd) {
|
|---|
| 177 | thdb->nrOfMsgs = 1;
|
|---|
| 178 | thdb->msgstate++; //odd -> next call to our PM window handler should dispatch the translated msg
|
|---|
| 179 | memcpy(&thdb->msg, msg, sizeof(MSG));
|
|---|
| 180 | }
|
|---|
| 181 | return (LONG)WinDispatchMsg(thdb->hab, &os2msg);
|
|---|
| 182 | }
|
|---|
| 183 | else {//is this allowed?
|
|---|
| 184 | // dprintf(("WARNING: OSLibWinDispatchMsg: called with own message!"));
|
|---|
| 185 | return SendMessageA(msg->hwnd, msg->message, msg->wParam, msg->lParam);
|
|---|
| 186 | }
|
|---|
| 187 | }
|
|---|
| 188 | //******************************************************************************
|
|---|
| 189 | //******************************************************************************
|
|---|
| 190 | BOOL OSLibWinGetMsg(LPMSG pMsg, HWND hwnd, UINT uMsgFilterMin, UINT uMsgFilterMax,
|
|---|
| 191 | BOOL isUnicode)
|
|---|
| 192 | {
|
|---|
| 193 | BOOL rc, eaten;
|
|---|
| 194 | THDB *thdb;
|
|---|
| 195 | QMSG os2msg;
|
|---|
| 196 |
|
|---|
| 197 | thdb = GetThreadTHDB();
|
|---|
| 198 | if(thdb == NULL) {
|
|---|
| 199 | DebugInt3();
|
|---|
| 200 | return FALSE;
|
|---|
| 201 | }
|
|---|
| 202 |
|
|---|
| 203 | if(thdb->fTranslated && (!hwnd || hwnd == thdb->msgWCHAR.hwnd)) {
|
|---|
| 204 | if(uMsgFilterMin) {
|
|---|
| 205 | if(thdb->msgWCHAR.message < uMsgFilterMin)
|
|---|
| 206 | goto continuegetmsg;
|
|---|
| 207 | }
|
|---|
| 208 | if(uMsgFilterMax) {
|
|---|
| 209 | if(thdb->msgWCHAR.message > uMsgFilterMax)
|
|---|
| 210 | goto continuegetmsg;
|
|---|
| 211 | }
|
|---|
| 212 | thdb->fTranslated = FALSE;
|
|---|
| 213 | memcpy(pMsg, &thdb->msgWCHAR, sizeof(MSG));
|
|---|
| 214 | MsgThreadPtr->msg = 0;
|
|---|
| 215 | MsgThreadPtr->hwnd = 0;
|
|---|
| 216 | return TRUE;
|
|---|
| 217 | }
|
|---|
| 218 |
|
|---|
| 219 | continuegetmsg:
|
|---|
| 220 | if(hwnd) {
|
|---|
| 221 | do {
|
|---|
| 222 | WinWaitMsg(thdb->hab, TranslateWinMsg(uMsgFilterMin, TRUE), TranslateWinMsg(uMsgFilterMax, FALSE));
|
|---|
| 223 | rc = OSLibWinPeekMsg(pMsg, hwnd, uMsgFilterMin, uMsgFilterMax, PM_REMOVE_W, isUnicode);
|
|---|
| 224 | }
|
|---|
| 225 | while(rc == FALSE);
|
|---|
| 226 |
|
|---|
| 227 | return rc;
|
|---|
| 228 | }
|
|---|
| 229 | else
|
|---|
| 230 | {
|
|---|
| 231 | do {
|
|---|
| 232 | eaten = FALSE;
|
|---|
| 233 | rc = WinGetMsg(thdb->hab, &os2msg, TranslateWinMsg(uMsgFilterMin, TRUE), TranslateWinMsg(uMsgFilterMax, FALSE), 0);
|
|---|
| 234 | if (os2msg.msg == WM_TIMER)
|
|---|
| 235 | eaten = TIMER_HandleTimer(&os2msg);
|
|---|
| 236 | } while (eaten);
|
|---|
| 237 | }
|
|---|
| 238 | if(rc) {
|
|---|
| 239 | OS2ToWinMsgTranslate((PVOID)thdb, &os2msg, pMsg, isUnicode, MSG_REMOVE);
|
|---|
| 240 | memcpy(MsgThreadPtr, &os2msg, sizeof(QMSG));
|
|---|
| 241 | }
|
|---|
| 242 | return rc;
|
|---|
| 243 | }
|
|---|
| 244 | //******************************************************************************
|
|---|
| 245 | //******************************************************************************
|
|---|
| 246 | BOOL OSLibWinPeekMsg(LPMSG pMsg, HWND hwnd, UINT uMsgFilterMin, UINT uMsgFilterMax,
|
|---|
| 247 | DWORD fRemove, BOOL isUnicode)
|
|---|
| 248 | {
|
|---|
| 249 | BOOL rc, eaten;
|
|---|
| 250 | THDB *thdb;
|
|---|
| 251 | QMSG os2msg;
|
|---|
| 252 |
|
|---|
| 253 | thdb = GetThreadTHDB();
|
|---|
| 254 | if(thdb == NULL) {
|
|---|
| 255 | DebugInt3();
|
|---|
| 256 | return FALSE;
|
|---|
| 257 | }
|
|---|
| 258 |
|
|---|
| 259 | if(thdb->fTranslated && (!hwnd || hwnd == thdb->msgWCHAR.hwnd)) {
|
|---|
| 260 | if(uMsgFilterMin) {
|
|---|
| 261 | if(thdb->msgWCHAR.message < uMsgFilterMin)
|
|---|
| 262 | goto continuepeekmsg;
|
|---|
| 263 | }
|
|---|
| 264 | if(uMsgFilterMax) {
|
|---|
| 265 | if(thdb->msgWCHAR.message > uMsgFilterMax)
|
|---|
| 266 | goto continuepeekmsg;
|
|---|
| 267 | }
|
|---|
| 268 |
|
|---|
| 269 | if(fRemove & PM_REMOVE_W) {
|
|---|
| 270 | thdb->fTranslated = FALSE;
|
|---|
| 271 | MsgThreadPtr->msg = 0;
|
|---|
| 272 | MsgThreadPtr->hwnd = 0;
|
|---|
| 273 | }
|
|---|
| 274 | memcpy(pMsg, &thdb->msgWCHAR, sizeof(MSG));
|
|---|
| 275 | return TRUE;
|
|---|
| 276 | }
|
|---|
| 277 | continuepeekmsg:
|
|---|
| 278 | do {
|
|---|
| 279 | eaten = FALSE;
|
|---|
| 280 | rc = WinPeekMsg(thdb->hab, &os2msg, Win32BaseWindow::OS2ToWin32Handle(hwnd), TranslateWinMsg(uMsgFilterMin, TRUE),
|
|---|
| 281 | TranslateWinMsg(uMsgFilterMax, FALSE), (fRemove & PM_REMOVE_W) ? PM_REMOVE : PM_NOREMOVE);
|
|---|
| 282 |
|
|---|
| 283 | if (rc && (fRemove & PM_REMOVE_W) && os2msg.msg == WM_TIMER) {
|
|---|
| 284 | eaten = TIMER_HandleTimer(&os2msg);
|
|---|
| 285 | }
|
|---|
| 286 | }
|
|---|
| 287 | while (eaten && rc);
|
|---|
| 288 |
|
|---|
| 289 | if(rc == FALSE) {
|
|---|
| 290 | return FALSE;
|
|---|
| 291 | }
|
|---|
| 292 |
|
|---|
| 293 | OS2ToWinMsgTranslate((PVOID)thdb, &os2msg, pMsg, isUnicode, (fRemove & PM_REMOVE_W) ? MSG_REMOVE : MSG_NOREMOVE);
|
|---|
| 294 | //TODO: This is not safe! There's no guarantee this message will be dispatched and it might overwrite a previous message
|
|---|
| 295 | if(fRemove & PM_REMOVE_W) {
|
|---|
| 296 | memcpy(MsgThreadPtr, &os2msg, sizeof(QMSG));
|
|---|
| 297 | }
|
|---|
| 298 | return rc;
|
|---|
| 299 | }
|
|---|
| 300 | //******************************************************************************
|
|---|
| 301 | //******************************************************************************
|
|---|
| 302 | ULONG OSLibWinQueryMsgTime()
|
|---|
| 303 | {
|
|---|
| 304 | return WinQueryMsgTime(GetThreadHAB());
|
|---|
| 305 | }
|
|---|
| 306 | //******************************************************************************
|
|---|
| 307 | //******************************************************************************
|
|---|
| 308 | BOOL OSLibWinWaitMessage()
|
|---|
| 309 | {
|
|---|
| 310 | return WinWaitMsg(GetThreadHAB(), 0, 0);
|
|---|
| 311 | }
|
|---|
| 312 | //******************************************************************************
|
|---|
| 313 | //TODO: QS_HOTKEY
|
|---|
| 314 | //******************************************************************************
|
|---|
| 315 | ULONG OSLibWinQueryQueueStatus()
|
|---|
| 316 | {
|
|---|
| 317 | ULONG statusOS2, statusWin32 = 0;
|
|---|
| 318 |
|
|---|
| 319 | statusOS2 = WinQueryQueueStatus(HWND_DESKTOP);
|
|---|
| 320 |
|
|---|
| 321 | if(statusOS2 & QS_KEY)
|
|---|
| 322 | statusWin32 |= QS_KEY_W;
|
|---|
| 323 | if(statusOS2 & QS_MOUSEBUTTON)
|
|---|
| 324 | statusWin32 |= QS_MOUSEBUTTON_W;
|
|---|
| 325 | if(statusOS2 & QS_MOUSEMOVE)
|
|---|
| 326 | statusWin32 |= QS_MOUSEMOVE_W;
|
|---|
| 327 | if(statusOS2 & QS_TIMER)
|
|---|
| 328 | statusWin32 |= QS_TIMER_W;
|
|---|
| 329 | if(statusOS2 & QS_PAINT)
|
|---|
| 330 | statusWin32 |= QS_PAINT_W;
|
|---|
| 331 | if(statusOS2 & QS_POSTMSG)
|
|---|
| 332 | statusWin32 |= QS_POSTMESSAGE_W;
|
|---|
| 333 | if(statusOS2 & QS_SENDMSG)
|
|---|
| 334 | statusWin32 |= QS_SENDMESSAGE_W;
|
|---|
| 335 |
|
|---|
| 336 | return statusWin32;
|
|---|
| 337 | }
|
|---|
| 338 | //******************************************************************************
|
|---|
| 339 | //******************************************************************************
|
|---|
| 340 | BOOL OSLibWinInSendMessage()
|
|---|
| 341 | {
|
|---|
| 342 | return WinInSendMsg(GetThreadHAB());
|
|---|
| 343 | }
|
|---|
| 344 | //******************************************************************************
|
|---|
| 345 | //******************************************************************************
|
|---|
| 346 | DWORD OSLibWinGetMessagePos()
|
|---|
| 347 | {
|
|---|
| 348 | APIRET rc;
|
|---|
| 349 | POINTL ptl;
|
|---|
| 350 |
|
|---|
| 351 | rc = WinQueryMsgPos(GetThreadHAB(), &ptl);
|
|---|
| 352 | if(!rc) {
|
|---|
| 353 | return 0;
|
|---|
| 354 | }
|
|---|
| 355 | //convert to windows coordinates
|
|---|
| 356 | return MAKEULONG(ptl.x,mapScreenY(ptl.y));
|
|---|
| 357 | }
|
|---|
| 358 | //******************************************************************************
|
|---|
| 359 | //******************************************************************************
|
|---|
| 360 | LONG OSLibWinGetMessageTime()
|
|---|
| 361 | {
|
|---|
| 362 | return (LONG)WinQueryMsgTime(GetThreadHAB());
|
|---|
| 363 | }
|
|---|
| 364 | //******************************************************************************
|
|---|
| 365 | //******************************************************************************
|
|---|
| 366 | BOOL OSLibWinReplyMessage(ULONG result)
|
|---|
| 367 | {
|
|---|
| 368 | return (BOOL)WinReplyMsg( NULLHANDLE, NULLHANDLE, HMQ_CURRENT, (MRESULT)result);
|
|---|
| 369 | }
|
|---|
| 370 | //******************************************************************************
|
|---|
| 371 | //******************************************************************************
|
|---|
| 372 | ULONG OSLibSendMessage(HWND hwnd, ULONG msg, ULONG wParam, ULONG lParam, BOOL fUnicode)
|
|---|
| 373 | {
|
|---|
| 374 | POSTMSG_PACKET *packet = (POSTMSG_PACKET *)_smalloc(sizeof(POSTMSG_PACKET));
|
|---|
| 375 |
|
|---|
| 376 | packet->Msg = msg;
|
|---|
| 377 | packet->wParam = wParam;
|
|---|
| 378 | packet->lParam = lParam;
|
|---|
| 379 |
|
|---|
| 380 | return (ULONG)WinSendMsg(hwnd, WIN32APP_POSTMSG, (MPARAM)((fUnicode) ? WIN32MSG_MAGICW : WIN32MSG_MAGICA), (MPARAM)packet);
|
|---|
| 381 | }
|
|---|
| 382 | //******************************************************************************
|
|---|
| 383 | //******************************************************************************
|
|---|
| 384 | ULONG OSLibWinBroadcastMsg(ULONG msg, ULONG wParam, ULONG lParam, BOOL fSend)
|
|---|
| 385 | {
|
|---|
| 386 | return WinBroadcastMsg(HWND_DESKTOP, msg, (MPARAM)wParam, (MPARAM)lParam,
|
|---|
| 387 | (fSend) ? BMSG_SEND : BMSG_POST);
|
|---|
| 388 | }
|
|---|
| 389 | //******************************************************************************
|
|---|
| 390 | //******************************************************************************
|
|---|
| 391 | BOOL OSLibPostMessage(HWND hwnd, ULONG msg, ULONG wParam, ULONG lParam, BOOL fUnicode)
|
|---|
| 392 | {
|
|---|
| 393 | POSTMSG_PACKET *packet = (POSTMSG_PACKET *)_smalloc(sizeof(POSTMSG_PACKET));
|
|---|
| 394 |
|
|---|
| 395 | packet->Msg = msg;
|
|---|
| 396 | packet->wParam = wParam;
|
|---|
| 397 | packet->lParam = lParam;
|
|---|
| 398 | return WinPostMsg(hwnd, WIN32APP_POSTMSG, (MPARAM)((fUnicode) ? WIN32MSG_MAGICW : WIN32MSG_MAGICA), (MPARAM)packet);
|
|---|
| 399 | }
|
|---|
| 400 | //******************************************************************************
|
|---|
| 401 | BOOL _System _O32_PostThreadMessage( DWORD, UINT, WPARAM, LPARAM );
|
|---|
| 402 |
|
|---|
| 403 | inline BOOL O32_PostThreadMessage(DWORD a, UINT b, WPARAM c, LPARAM d)
|
|---|
| 404 | {
|
|---|
| 405 | BOOL yyrc;
|
|---|
| 406 | USHORT sel = RestoreOS2FS();
|
|---|
| 407 |
|
|---|
| 408 | yyrc = _O32_PostThreadMessage(a, b, c, d);
|
|---|
| 409 | SetFS(sel);
|
|---|
| 410 |
|
|---|
| 411 | return yyrc;
|
|---|
| 412 | }
|
|---|
| 413 | //******************************************************************************
|
|---|
| 414 | BOOL OSLibPostThreadMessage(ULONG threadid, UINT msg, WPARAM wParam, LPARAM lParam, BOOL fUnicode)
|
|---|
| 415 | {
|
|---|
| 416 | // THDB *thdb = GetTHDBFromThreadId(threadid);
|
|---|
| 417 | POSTMSG_PACKET *packet = (POSTMSG_PACKET *)_smalloc(sizeof(POSTMSG_PACKET));
|
|---|
| 418 |
|
|---|
| 419 | // if(thdb == NULL) {
|
|---|
| 420 | // dprintf(("OSLibPostThreadMessage: thread %x not found!", threadid));
|
|---|
| 421 | // return FALSE;
|
|---|
| 422 | // }
|
|---|
| 423 | dprintf(("PostThreadMessageA %x %x %x %x", threadid, msg, wParam, lParam));
|
|---|
| 424 | packet->Msg = msg;
|
|---|
| 425 | packet->wParam = wParam;
|
|---|
| 426 | packet->lParam = lParam;
|
|---|
| 427 | return _O32_PostThreadMessage(threadid, WIN32APP_POSTMSG-OPEN32_MSGDIFF, ((fUnicode) ? WIN32MSG_MAGICW : WIN32MSG_MAGICA), (LPARAM)packet);
|
|---|
| 428 | }
|
|---|
| 429 | //******************************************************************************
|
|---|
| 430 | //******************************************************************************
|
|---|
| 431 |
|
|---|