| 1 | /* $Id: windowmsg.cpp,v 1.33 2002-02-05 17:59:02 sandervl Exp $ */
|
|---|
| 2 | /*
|
|---|
| 3 | * Win32 window message APIs for OS/2
|
|---|
| 4 | *
|
|---|
| 5 | * Copyright 1999-2001 Sander van Leeuwen
|
|---|
| 6 | *
|
|---|
| 7 | * Parts based on Wine Windows code (windows\message.c) 990508
|
|---|
| 8 | *
|
|---|
| 9 | * Copyright 1993, 1994 Alexandre Julliard
|
|---|
| 10 | *
|
|---|
| 11 | * TODO: GetQueueStatus: QS_HOTKEY (oslibmsg.cpp) & low word bits
|
|---|
| 12 | * TODO: MsgWaitForMultipleObjects: timeout isn't handled correctly (can return too late)
|
|---|
| 13 | *
|
|---|
| 14 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 15 | *
|
|---|
| 16 | */
|
|---|
| 17 |
|
|---|
| 18 | #include <odin.h>
|
|---|
| 19 | #include <odinwrap.h>
|
|---|
| 20 | #include <os2sel.h>
|
|---|
| 21 |
|
|---|
| 22 | #include <os2win.h>
|
|---|
| 23 | #include <misc.h>
|
|---|
| 24 | #include <win32wbase.h>
|
|---|
| 25 | #include <win.h>
|
|---|
| 26 | #include <heapstring.h>
|
|---|
| 27 | #include <handlemanager.h>
|
|---|
| 28 | #include "oslibutil.h"
|
|---|
| 29 | #include "oslibwin.h"
|
|---|
| 30 | #include "oslibmsg.h"
|
|---|
| 31 | #include "hook.h"
|
|---|
| 32 |
|
|---|
| 33 | #define DBG_LOCALLOG DBG_windowmsg
|
|---|
| 34 | #include "dbglocal.h"
|
|---|
| 35 |
|
|---|
| 36 | ODINDEBUGCHANNEL(USER32-WINDOWMSG)
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 | //******************************************************************************
|
|---|
| 40 | //******************************************************************************
|
|---|
| 41 | LONG WIN32API DispatchMessageA(const MSG * msg)
|
|---|
| 42 | {
|
|---|
| 43 | dprintf2(("DispatchMessageA %x %x %x %x %x", msg->hwnd, msg->message, msg->wParam, msg->lParam, msg->time));
|
|---|
| 44 | return OSLibWinDispatchMsg((MSG *)msg);
|
|---|
| 45 | }
|
|---|
| 46 | //******************************************************************************
|
|---|
| 47 | //******************************************************************************
|
|---|
| 48 | LONG WIN32API DispatchMessageW( const MSG * msg)
|
|---|
| 49 | {
|
|---|
| 50 | dprintf2(("DispatchMessageW %x %x %x %x %x", msg->hwnd, msg->message, msg->wParam, msg->lParam, msg->time));
|
|---|
| 51 | return OSLibWinDispatchMsg((MSG *)msg, TRUE);
|
|---|
| 52 | }
|
|---|
| 53 | //******************************************************************************
|
|---|
| 54 | //******************************************************************************
|
|---|
| 55 | BOOL WIN32API TranslateMessage(const MSG *msg)
|
|---|
| 56 | {
|
|---|
| 57 | // check the message code
|
|---|
| 58 | if ( (msg->message < WM_KEYDOWN) ||
|
|---|
| 59 | (msg->message > WM_SYSKEYUP)||
|
|---|
| 60 | (msg->message == WM_CHAR) ||
|
|---|
| 61 | (msg->message == WM_DEADCHAR) )
|
|---|
| 62 | {
|
|---|
| 63 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 64 | return FALSE;
|
|---|
| 65 | }
|
|---|
| 66 |
|
|---|
| 67 | // only WM_KEYDOWN, WM_KEYUP, WM_SYSKEYDOWN, WM_SYSKEYUP
|
|---|
| 68 | // can go into TranslateMessage
|
|---|
| 69 |
|
|---|
| 70 | return OSLibWinTranslateMessage((MSG *)msg);
|
|---|
| 71 | }
|
|---|
| 72 | //******************************************************************************
|
|---|
| 73 | //******************************************************************************
|
|---|
| 74 | BOOL WIN32API GetMessageA( LPMSG pMsg, HWND hwnd, UINT uMsgFilterMin, UINT uMsgFilterMax)
|
|---|
| 75 | {
|
|---|
| 76 | BOOL ret;
|
|---|
| 77 |
|
|---|
| 78 | dprintf2(("GetMessageA %x %x-%x", hwnd, uMsgFilterMin, uMsgFilterMax));
|
|---|
| 79 | ret = OSLibWinGetMsg(pMsg, hwnd, uMsgFilterMin, uMsgFilterMax);
|
|---|
| 80 | if(ret) dprintf2(("GetMessageA %x %x %x %x", hwnd, pMsg->message, pMsg->wParam, pMsg->lParam));
|
|---|
| 81 | HOOK_CallHooksA(WH_GETMESSAGE, HC_ACTION, PM_REMOVE, (LPARAM)pMsg);
|
|---|
| 82 | return ret;
|
|---|
| 83 | }
|
|---|
| 84 | //******************************************************************************
|
|---|
| 85 | //******************************************************************************
|
|---|
| 86 | BOOL WIN32API GetMessageW( LPMSG pMsg, HWND hwnd, UINT uMsgFilterMin, UINT uMsgFilterMax)
|
|---|
| 87 | {
|
|---|
| 88 | BOOL ret;
|
|---|
| 89 |
|
|---|
| 90 | dprintf2(("GetMessageW %x %x-%x", hwnd, uMsgFilterMin, uMsgFilterMax));
|
|---|
| 91 | ret = OSLibWinGetMsg(pMsg, hwnd, uMsgFilterMin, uMsgFilterMax, TRUE);
|
|---|
| 92 | HOOK_CallHooksW(WH_GETMESSAGE, HC_ACTION, PM_REMOVE, (LPARAM)pMsg);
|
|---|
| 93 | return ret;
|
|---|
| 94 | }
|
|---|
| 95 | //******************************************************************************
|
|---|
| 96 | //******************************************************************************
|
|---|
| 97 | BOOL WIN32API PeekMessageA(LPMSG msg, HWND hwndOwner, UINT uMsgFilterMin,
|
|---|
| 98 | UINT uMsgFilterMax, UINT fuRemoveMsg)
|
|---|
| 99 | {
|
|---|
| 100 | BOOL fFoundMsg;
|
|---|
| 101 |
|
|---|
| 102 | dprintf2(("PeekMessageA %x %d-%d %d", hwndOwner, uMsgFilterMin, uMsgFilterMax, fuRemoveMsg));
|
|---|
| 103 | fFoundMsg = OSLibWinPeekMsg(msg, hwndOwner, uMsgFilterMin, uMsgFilterMax,
|
|---|
| 104 | fuRemoveMsg, FALSE);
|
|---|
| 105 | if(fFoundMsg) {
|
|---|
| 106 | dprintf2(("PeekMessageA %x %d-%d %d found message %x %d %x %x", hwndOwner, uMsgFilterMin, uMsgFilterMax, fuRemoveMsg, msg->hwnd, msg->message, msg->wParam, msg->lParam));
|
|---|
| 107 | HOOK_CallHooksA(WH_GETMESSAGE, HC_ACTION, fuRemoveMsg & PM_REMOVE, (LPARAM)msg );
|
|---|
| 108 | if (msg->message == WM_QUIT && (fuRemoveMsg & PM_REMOVE)) {
|
|---|
| 109 | //TODO: Post WM_QUERYENDSESSION message when WM_QUIT received and system is shutting down
|
|---|
| 110 | }
|
|---|
| 111 | }
|
|---|
| 112 | return fFoundMsg;
|
|---|
| 113 | }
|
|---|
| 114 | //******************************************************************************
|
|---|
| 115 | //******************************************************************************
|
|---|
| 116 | BOOL WIN32API PeekMessageW(LPMSG msg, HWND hwndOwner, UINT uMsgFilterMin,
|
|---|
| 117 | UINT uMsgFilterMax, UINT fuRemoveMsg)
|
|---|
| 118 | {
|
|---|
| 119 | BOOL fFoundMsg;
|
|---|
| 120 |
|
|---|
| 121 | dprintf2(("PeekMessageW %x %d-%d %d", hwndOwner, uMsgFilterMin, uMsgFilterMax, fuRemoveMsg));
|
|---|
| 122 | fFoundMsg = OSLibWinPeekMsg(msg, hwndOwner, uMsgFilterMin, uMsgFilterMax,
|
|---|
| 123 | fuRemoveMsg, TRUE);
|
|---|
| 124 | if(fFoundMsg) {
|
|---|
| 125 | dprintf2(("PeekMessageW %x %d-%d %d found message %x %d %x %x", hwndOwner, uMsgFilterMin, uMsgFilterMax, fuRemoveMsg, msg->hwnd, msg->message, msg->wParam, msg->lParam));
|
|---|
| 126 | HOOK_CallHooksW(WH_GETMESSAGE, HC_ACTION, fuRemoveMsg & PM_REMOVE, (LPARAM)msg );
|
|---|
| 127 | if (msg->message == WM_QUIT && (fuRemoveMsg & (PM_REMOVE))) {
|
|---|
| 128 | //TODO: Post WM_QUERYENDSESSION message when WM_QUIT received and system is shutting down
|
|---|
| 129 | }
|
|---|
| 130 | }
|
|---|
| 131 | return fFoundMsg;
|
|---|
| 132 | }
|
|---|
| 133 | //******************************************************************************
|
|---|
| 134 | //TODO:
|
|---|
| 135 | //******************************************************************************
|
|---|
| 136 | LONG WIN32API GetMessageExtraInfo()
|
|---|
| 137 | {
|
|---|
| 138 | dprintf(("USER32: GetMessageExtraInfo %x", GetThreadMessageExtraInfo()));
|
|---|
| 139 | return GetThreadMessageExtraInfo();
|
|---|
| 140 | }
|
|---|
| 141 | //******************************************************************************
|
|---|
| 142 | //******************************************************************************
|
|---|
| 143 | LPARAM WIN32API SetMessageExtraInfo(LPARAM lParam)
|
|---|
| 144 | {
|
|---|
| 145 | dprintf(("USER32: SetMessageExtraInfo %x", lParam));
|
|---|
| 146 | return SetThreadMessageExtraInfo(lParam);
|
|---|
| 147 | }
|
|---|
| 148 | //******************************************************************************
|
|---|
| 149 | //******************************************************************************
|
|---|
| 150 | DWORD WIN32API GetMessagePos(void)
|
|---|
| 151 | {
|
|---|
| 152 | DWORD pos;
|
|---|
| 153 |
|
|---|
| 154 | pos = OSLibWinGetMessagePos();
|
|---|
| 155 | dprintf(("USER32: GetMessagePos -> (%d,%d)", HIWORD(pos), LOWORD(pos)));
|
|---|
| 156 | return pos;
|
|---|
| 157 | }
|
|---|
| 158 | //******************************************************************************
|
|---|
| 159 | //******************************************************************************
|
|---|
| 160 | LONG WIN32API GetMessageTime(void)
|
|---|
| 161 | {
|
|---|
| 162 | dprintf(("USER32: GetMessageTime"));
|
|---|
| 163 | return OSLibWinGetMessageTime();
|
|---|
| 164 | }
|
|---|
| 165 | //******************************************************************************
|
|---|
| 166 | //******************************************************************************
|
|---|
| 167 | BOOL WIN32API WaitMessage(void)
|
|---|
| 168 | {
|
|---|
| 169 | dprintf2(("USER32: WaitMessage"));
|
|---|
| 170 | return OSLibWinWaitMessage();
|
|---|
| 171 | }
|
|---|
| 172 | //******************************************************************************
|
|---|
| 173 | //******************************************************************************
|
|---|
| 174 | BOOL WIN32API InSendMessage(void)
|
|---|
| 175 | {
|
|---|
| 176 | dprintf(("USER32: InSendMessage"));
|
|---|
| 177 | return OSLibWinInSendMessage();
|
|---|
| 178 | }
|
|---|
| 179 | //******************************************************************************
|
|---|
| 180 | //******************************************************************************
|
|---|
| 181 | BOOL WIN32API ReplyMessage(LRESULT result)
|
|---|
| 182 | {
|
|---|
| 183 | dprintf(("USER32: ReplyMessage %x", result));
|
|---|
| 184 | return OSLibWinReplyMessage(result);
|
|---|
| 185 | }
|
|---|
| 186 | //******************************************************************************
|
|---|
| 187 | //******************************************************************************
|
|---|
| 188 | VOID WIN32API PostQuitMessage( int nExitCode)
|
|---|
| 189 | {
|
|---|
| 190 | dprintf(("USER32: PostQuitMessage\n"));
|
|---|
| 191 | OSLibWinPostQuitMessage(nExitCode);
|
|---|
| 192 | }
|
|---|
| 193 | //******************************************************************************
|
|---|
| 194 | //******************************************************************************
|
|---|
| 195 | UINT WIN32API RegisterWindowMessageA(LPCSTR lpString)
|
|---|
| 196 | {
|
|---|
| 197 | UINT rc;
|
|---|
| 198 |
|
|---|
| 199 | rc = GlobalAddAtomA(lpString);
|
|---|
| 200 | dprintf(("USER32: RegisterWindowMessageA %s returned %X\n", lpString, rc));
|
|---|
| 201 | return(rc);
|
|---|
| 202 | }
|
|---|
| 203 | //******************************************************************************
|
|---|
| 204 | //******************************************************************************
|
|---|
| 205 | UINT WIN32API RegisterWindowMessageW( LPCWSTR lpString)
|
|---|
| 206 | {
|
|---|
| 207 | dprintf(("USER32: RegisterWindowMessageW\n"));
|
|---|
| 208 | return GlobalAddAtomW(lpString);
|
|---|
| 209 | }
|
|---|
| 210 | //******************************************************************************
|
|---|
| 211 | //No need to support this (obsolete, not implemented by Win32)
|
|---|
| 212 | //******************************************************************************
|
|---|
| 213 | BOOL WIN32API SetMessageQueue(int cMessagesMax)
|
|---|
| 214 | {
|
|---|
| 215 | dprintf(("USER32: SetMessageQueue\n"));
|
|---|
| 216 | return(TRUE);
|
|---|
| 217 | }
|
|---|
| 218 | //******************************************************************************
|
|---|
| 219 | //******************************************************************************
|
|---|
| 220 | /**********************************************************************
|
|---|
| 221 | * WINPROC_TestCBForStr
|
|---|
| 222 | *
|
|---|
| 223 | * Return TRUE if the lparam is a string
|
|---|
| 224 | */
|
|---|
| 225 | BOOL WINPROC_TestCBForStr ( HWND hwnd )
|
|---|
| 226 | {
|
|---|
| 227 | BOOL retvalue;
|
|---|
| 228 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
|
|---|
| 229 | retvalue = ( !(LOWORD(dwStyle) & (CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE)) ||
|
|---|
| 230 | (LOWORD(dwStyle) & CBS_HASSTRINGS) );
|
|---|
| 231 | return retvalue;
|
|---|
| 232 | }
|
|---|
| 233 | /**********************************************************************
|
|---|
| 234 | * WINPROC_TestLBForStr
|
|---|
| 235 | *
|
|---|
| 236 | * Return TRUE if the lparam is a string
|
|---|
| 237 | */
|
|---|
| 238 | BOOL WINPROC_TestLBForStr ( HWND hwnd )
|
|---|
| 239 | {
|
|---|
| 240 | BOOL retvalue;
|
|---|
| 241 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
|
|---|
| 242 | retvalue = ( !(LOWORD(dwStyle) & (LBS_OWNERDRAWFIXED | LBS_OWNERDRAWVARIABLE)) ||
|
|---|
| 243 | (LOWORD(dwStyle) & LBS_HASSTRINGS) );
|
|---|
| 244 | return retvalue;
|
|---|
| 245 | }
|
|---|
| 246 |
|
|---|
| 247 | /**********************************************************************
|
|---|
| 248 | * WINPROC_MapMsg32ATo32W
|
|---|
| 249 | *
|
|---|
| 250 | * Map a message from Ansi to Unicode.
|
|---|
| 251 | * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
|
|---|
| 252 | *
|
|---|
| 253 | * FIXME:
|
|---|
| 254 | * WM_CHAR, WM_CHARTOITEM, WM_DEADCHAR, WM_MENUCHAR, WM_SYSCHAR, WM_SYSDEADCHAR
|
|---|
| 255 | *
|
|---|
| 256 | * FIXME:
|
|---|
| 257 | * WM_GETTEXT/WM_SETTEXT and static control with SS_ICON style:
|
|---|
| 258 | * the first four bytes are the handle of the icon
|
|---|
| 259 | * when the WM_SETTEXT message has been used to set the icon
|
|---|
| 260 | */
|
|---|
| 261 | INT WINPROC_MapMsg32ATo32W( HWND hwnd, UINT msg, WPARAM wParam, LPARAM *plparam )
|
|---|
| 262 | {
|
|---|
| 263 | switch(msg)
|
|---|
| 264 | {
|
|---|
| 265 | case WM_GETTEXT:
|
|---|
| 266 | {
|
|---|
| 267 | LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0,
|
|---|
| 268 | wParam * sizeof(WCHAR) + sizeof(LPARAM) );
|
|---|
| 269 | if (!ptr) return -1;
|
|---|
| 270 | *ptr++ = *plparam; /* Store previous lParam */
|
|---|
| 271 | *plparam = (LPARAM)ptr;
|
|---|
| 272 | }
|
|---|
| 273 | return 1;
|
|---|
| 274 | /* lparam is string (0-terminated) */
|
|---|
| 275 | case WM_SETTEXT:
|
|---|
| 276 | case WM_WININICHANGE:
|
|---|
| 277 | case CB_DIR:
|
|---|
| 278 | case LB_DIR:
|
|---|
| 279 | case LB_ADDFILE:
|
|---|
| 280 | #ifndef __WIN32OS2__
|
|---|
| 281 | case CB_FINDSTRING:
|
|---|
| 282 | case CB_FINDSTRINGEXACT:
|
|---|
| 283 | case CB_SELECTSTRING:
|
|---|
| 284 | case LB_FINDSTRING:
|
|---|
| 285 | case LB_SELECTSTRING:
|
|---|
| 286 | #endif
|
|---|
| 287 | case EM_REPLACESEL:
|
|---|
| 288 | *plparam = (LPARAM)HEAP_strdupAtoW( GetProcessHeap(), 0, (LPCSTR)*plparam );
|
|---|
| 289 | return (*plparam ? 1 : -1);
|
|---|
| 290 |
|
|---|
| 291 | case WM_NCCREATE:
|
|---|
| 292 | case WM_CREATE:
|
|---|
| 293 | {
|
|---|
| 294 | CREATESTRUCTW *cs = (CREATESTRUCTW *)HeapAlloc( GetProcessHeap(), 0,
|
|---|
| 295 | sizeof(*cs) );
|
|---|
| 296 | if (!cs) return -1;
|
|---|
| 297 | *cs = *(CREATESTRUCTW *)*plparam;
|
|---|
| 298 | if (HIWORD(cs->lpszName))
|
|---|
| 299 | cs->lpszName = HEAP_strdupAtoW( GetProcessHeap(), 0,
|
|---|
| 300 | (LPCSTR)cs->lpszName );
|
|---|
| 301 | if (HIWORD(cs->lpszClass))
|
|---|
| 302 | cs->lpszClass = HEAP_strdupAtoW( GetProcessHeap(), 0,
|
|---|
| 303 | (LPCSTR)cs->lpszClass );
|
|---|
| 304 | *plparam = (LPARAM)cs;
|
|---|
| 305 | }
|
|---|
| 306 | return 1;
|
|---|
| 307 | case WM_MDICREATE:
|
|---|
| 308 | {
|
|---|
| 309 | MDICREATESTRUCTW *cs =
|
|---|
| 310 | (MDICREATESTRUCTW *)HeapAlloc( GetProcessHeap(), 0, sizeof(*cs) );
|
|---|
| 311 | if (!cs) return -1;
|
|---|
| 312 | *cs = *(MDICREATESTRUCTW *)*plparam;
|
|---|
| 313 | if (HIWORD(cs->szClass))
|
|---|
| 314 | cs->szClass = HEAP_strdupAtoW( GetProcessHeap(), 0,
|
|---|
| 315 | (LPCSTR)cs->szClass );
|
|---|
| 316 | if (HIWORD(cs->szTitle))
|
|---|
| 317 | cs->szTitle = HEAP_strdupAtoW( GetProcessHeap(), 0,
|
|---|
| 318 | (LPCSTR)cs->szTitle );
|
|---|
| 319 | *plparam = (LPARAM)cs;
|
|---|
| 320 | }
|
|---|
| 321 | return 1;
|
|---|
| 322 |
|
|---|
| 323 | /* Listbox */
|
|---|
| 324 | case LB_ADDSTRING:
|
|---|
| 325 | #ifdef __WIN32OS2__
|
|---|
| 326 | case LB_FINDSTRING:
|
|---|
| 327 | case LB_FINDSTRINGEXACT:
|
|---|
| 328 | case LB_SELECTSTRING:
|
|---|
| 329 | #endif
|
|---|
| 330 | case LB_INSERTSTRING:
|
|---|
| 331 | if ( WINPROC_TestLBForStr( hwnd ))
|
|---|
| 332 | *plparam = (LPARAM)HEAP_strdupAtoW( GetProcessHeap(), 0, (LPCSTR)*plparam );
|
|---|
| 333 | return (*plparam ? 1 : -1);
|
|---|
| 334 |
|
|---|
| 335 | case LB_GETTEXT: /* fixme: fixed sized buffer */
|
|---|
| 336 | { if ( WINPROC_TestLBForStr( hwnd ))
|
|---|
| 337 | { LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0, 256 * sizeof(WCHAR) + sizeof(LPARAM) );
|
|---|
| 338 | if (!ptr) return -1;
|
|---|
| 339 | *ptr++ = *plparam; /* Store previous lParam */
|
|---|
| 340 | *plparam = (LPARAM)ptr;
|
|---|
| 341 | }
|
|---|
| 342 | }
|
|---|
| 343 | return 1;
|
|---|
| 344 |
|
|---|
| 345 | /* Combobox */
|
|---|
| 346 | case CB_ADDSTRING:
|
|---|
| 347 | #ifdef __WIN32OS2__
|
|---|
| 348 | case CB_FINDSTRING:
|
|---|
| 349 | case CB_FINDSTRINGEXACT:
|
|---|
| 350 | case CB_SELECTSTRING:
|
|---|
| 351 | #endif
|
|---|
| 352 | case CB_INSERTSTRING:
|
|---|
| 353 | if ( WINPROC_TestCBForStr( hwnd ))
|
|---|
| 354 | *plparam = (LPARAM)HEAP_strdupAtoW( GetProcessHeap(), 0, (LPCSTR)*plparam );
|
|---|
| 355 | return (*plparam ? 1 : -1);
|
|---|
| 356 |
|
|---|
| 357 | case CB_GETLBTEXT: /* fixme: fixed sized buffer */
|
|---|
| 358 | { if ( WINPROC_TestCBForStr( hwnd ))
|
|---|
| 359 | { LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0, 256 * sizeof(WCHAR) + sizeof(LPARAM) );
|
|---|
| 360 | if (!ptr) return -1;
|
|---|
| 361 | *ptr++ = *plparam; /* Store previous lParam */
|
|---|
| 362 | *plparam = (LPARAM)ptr;
|
|---|
| 363 | }
|
|---|
| 364 | }
|
|---|
| 365 | return 1;
|
|---|
| 366 |
|
|---|
| 367 | /* Multiline edit */
|
|---|
| 368 | case EM_GETLINE:
|
|---|
| 369 | { WORD len = (WORD)*plparam;
|
|---|
| 370 | LPARAM *ptr = (LPARAM *) HEAP_xalloc( GetProcessHeap(), 0, sizeof(LPARAM) + sizeof (WORD) + len*sizeof(WCHAR) );
|
|---|
| 371 | if (!ptr) return -1;
|
|---|
| 372 | *ptr++ = *plparam; /* Store previous lParam */
|
|---|
| 373 | *((WORD *) ptr) = len; /* Store the length */
|
|---|
| 374 | *plparam = (LPARAM)ptr;
|
|---|
| 375 | }
|
|---|
| 376 | return 1;
|
|---|
| 377 |
|
|---|
| 378 | case WM_ASKCBFORMATNAME:
|
|---|
| 379 | case WM_DEVMODECHANGE:
|
|---|
| 380 | case WM_PAINTCLIPBOARD:
|
|---|
| 381 | case WM_SIZECLIPBOARD:
|
|---|
| 382 | case EM_SETPASSWORDCHAR:
|
|---|
| 383 | // FIXME_(msg)("message %s (0x%x) needs translation, please report\n", SPY_GetMsgName(msg), msg );
|
|---|
| 384 | return -1;
|
|---|
| 385 | default: /* No translation needed */
|
|---|
| 386 | return 0;
|
|---|
| 387 | }
|
|---|
| 388 | }
|
|---|
| 389 |
|
|---|
| 390 |
|
|---|
| 391 | /**********************************************************************
|
|---|
| 392 | * WINPROC_UnmapMsg32ATo32W
|
|---|
| 393 | *
|
|---|
| 394 | * Unmap a message that was mapped from Ansi to Unicode.
|
|---|
| 395 | */
|
|---|
| 396 | void WINPROC_UnmapMsg32ATo32W( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
|
|---|
| 397 | {
|
|---|
| 398 | switch(msg)
|
|---|
| 399 | {
|
|---|
| 400 | case WM_GETTEXT:
|
|---|
| 401 | {
|
|---|
| 402 | LPARAM *ptr = (LPARAM *)lParam - 1;
|
|---|
| 403 | lstrcpynWtoA( (LPSTR)*ptr, (LPWSTR)lParam, wParam );
|
|---|
| 404 | HeapFree( GetProcessHeap(), 0, ptr );
|
|---|
| 405 | }
|
|---|
| 406 | break;
|
|---|
| 407 |
|
|---|
| 408 | case WM_NCCREATE:
|
|---|
| 409 | case WM_CREATE:
|
|---|
| 410 | {
|
|---|
| 411 | CREATESTRUCTW *cs = (CREATESTRUCTW *)lParam;
|
|---|
| 412 | if (HIWORD(cs->lpszName))
|
|---|
| 413 | HeapFree( GetProcessHeap(), 0, (LPVOID)cs->lpszName );
|
|---|
| 414 | if (HIWORD(cs->lpszClass))
|
|---|
| 415 | HeapFree( GetProcessHeap(), 0, (LPVOID)cs->lpszClass );
|
|---|
| 416 | HeapFree( GetProcessHeap(), 0, cs );
|
|---|
| 417 | }
|
|---|
| 418 | break;
|
|---|
| 419 |
|
|---|
| 420 | case WM_MDICREATE:
|
|---|
| 421 | {
|
|---|
| 422 | MDICREATESTRUCTW *cs = (MDICREATESTRUCTW *)lParam;
|
|---|
| 423 | if (HIWORD(cs->szTitle))
|
|---|
| 424 | HeapFree( GetProcessHeap(), 0, (LPVOID)cs->szTitle );
|
|---|
| 425 | if (HIWORD(cs->szClass))
|
|---|
| 426 | HeapFree( GetProcessHeap(), 0, (LPVOID)cs->szClass );
|
|---|
| 427 | HeapFree( GetProcessHeap(), 0, cs );
|
|---|
| 428 | }
|
|---|
| 429 | break;
|
|---|
| 430 |
|
|---|
| 431 | case WM_SETTEXT:
|
|---|
| 432 | case WM_WININICHANGE:
|
|---|
| 433 | case CB_DIR:
|
|---|
| 434 | case LB_DIR:
|
|---|
| 435 | case LB_ADDFILE:
|
|---|
| 436 | #ifndef __WIN32OS2__
|
|---|
| 437 | case CB_FINDSTRING:
|
|---|
| 438 | case CB_FINDSTRINGEXACT:
|
|---|
| 439 | case CB_SELECTSTRING:
|
|---|
| 440 | case LB_FINDSTRING:
|
|---|
| 441 | case LB_SELECTSTRING:
|
|---|
| 442 | #endif
|
|---|
| 443 | case EM_REPLACESEL:
|
|---|
| 444 | HeapFree( GetProcessHeap(), 0, (void *)lParam );
|
|---|
| 445 | break;
|
|---|
| 446 |
|
|---|
| 447 | /* Listbox */
|
|---|
| 448 | case LB_ADDSTRING:
|
|---|
| 449 | #ifdef __WIN32OS2__
|
|---|
| 450 | case LB_FINDSTRING:
|
|---|
| 451 | case LB_FINDSTRINGEXACT:
|
|---|
| 452 | case LB_SELECTSTRING:
|
|---|
| 453 | #endif
|
|---|
| 454 | case LB_INSERTSTRING:
|
|---|
| 455 | if ( WINPROC_TestLBForStr( hwnd ))
|
|---|
| 456 | HeapFree( GetProcessHeap(), 0, (void *)lParam );
|
|---|
| 457 | break;
|
|---|
| 458 |
|
|---|
| 459 | case LB_GETTEXT:
|
|---|
| 460 | { if ( WINPROC_TestLBForStr( hwnd ))
|
|---|
| 461 | { LPARAM *ptr = (LPARAM *)lParam - 1;
|
|---|
| 462 | lstrcpyWtoA( (LPSTR)*ptr, (LPWSTR)(lParam) );
|
|---|
| 463 | HeapFree( GetProcessHeap(), 0, ptr );
|
|---|
| 464 | }
|
|---|
| 465 | }
|
|---|
| 466 | break;
|
|---|
| 467 |
|
|---|
| 468 | /* Combobox */
|
|---|
| 469 | case CB_ADDSTRING:
|
|---|
| 470 | #ifdef __WIN32OS2__
|
|---|
| 471 | case CB_FINDSTRING:
|
|---|
| 472 | case CB_FINDSTRINGEXACT:
|
|---|
| 473 | case CB_SELECTSTRING:
|
|---|
| 474 | #endif
|
|---|
| 475 | case CB_INSERTSTRING:
|
|---|
| 476 | if ( WINPROC_TestCBForStr( hwnd ))
|
|---|
| 477 | HeapFree( GetProcessHeap(), 0, (void *)lParam );
|
|---|
| 478 | break;
|
|---|
| 479 |
|
|---|
| 480 | case CB_GETLBTEXT:
|
|---|
| 481 | { if ( WINPROC_TestCBForStr( hwnd ))
|
|---|
| 482 | { LPARAM *ptr = (LPARAM *)lParam - 1;
|
|---|
| 483 | lstrcpyWtoA( (LPSTR)*ptr, (LPWSTR)(lParam) );
|
|---|
| 484 | HeapFree( GetProcessHeap(), 0, ptr );
|
|---|
| 485 | }
|
|---|
| 486 | }
|
|---|
| 487 | break;
|
|---|
| 488 |
|
|---|
| 489 | /* Multiline edit */
|
|---|
| 490 | case EM_GETLINE:
|
|---|
| 491 | { LPARAM * ptr = (LPARAM *)lParam - 1; /* get the old lParam */
|
|---|
| 492 | WORD len = *(WORD *) lParam;
|
|---|
| 493 | lstrcpynWtoA( (LPSTR)*ptr , (LPWSTR)lParam, len );
|
|---|
| 494 | HeapFree( GetProcessHeap(), 0, ptr );
|
|---|
| 495 | }
|
|---|
| 496 | break;
|
|---|
| 497 | }
|
|---|
| 498 | }
|
|---|
| 499 |
|
|---|
| 500 |
|
|---|
| 501 | /**********************************************************************
|
|---|
| 502 | * WINPROC_MapMsg32WTo32A
|
|---|
| 503 | *
|
|---|
| 504 | * Map a message from Unicode to Ansi.
|
|---|
| 505 | * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
|
|---|
| 506 | */
|
|---|
| 507 | INT WINPROC_MapMsg32WTo32A( HWND hwnd, UINT msg, WPARAM wParam, LPARAM *plparam)
|
|---|
| 508 | { switch(msg)
|
|---|
| 509 | {
|
|---|
| 510 | case WM_GETTEXT:
|
|---|
| 511 | {
|
|---|
| 512 | LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0,
|
|---|
| 513 | wParam + sizeof(LPARAM) );
|
|---|
| 514 | if (!ptr) return -1;
|
|---|
| 515 | *ptr++ = *plparam; /* Store previous lParam */
|
|---|
| 516 | *plparam = (LPARAM)ptr;
|
|---|
| 517 | }
|
|---|
| 518 | return 1;
|
|---|
| 519 |
|
|---|
| 520 | case WM_SETTEXT:
|
|---|
| 521 | case WM_WININICHANGE:
|
|---|
| 522 | case CB_DIR:
|
|---|
| 523 | case LB_DIR:
|
|---|
| 524 | case LB_ADDFILE:
|
|---|
| 525 | #ifndef __WIN32OS2__
|
|---|
| 526 | case CB_FINDSTRING:
|
|---|
| 527 | case CB_FINDSTRINGEXACT:
|
|---|
| 528 | case CB_SELECTSTRING:
|
|---|
| 529 | case LB_FINDSTRING:
|
|---|
| 530 | case LB_SELECTSTRING:
|
|---|
| 531 | #endif
|
|---|
| 532 | case EM_REPLACESEL:
|
|---|
| 533 | *plparam = (LPARAM)HEAP_strdupWtoA( GetProcessHeap(), 0, (LPCWSTR)*plparam );
|
|---|
| 534 | return (*plparam ? 1 : -1);
|
|---|
| 535 |
|
|---|
| 536 | case WM_NCCREATE:
|
|---|
| 537 | case WM_CREATE:
|
|---|
| 538 | {
|
|---|
| 539 | CREATESTRUCTA *cs = (CREATESTRUCTA *)HeapAlloc( GetProcessHeap(), 0,
|
|---|
| 540 | sizeof(*cs) );
|
|---|
| 541 | if (!cs) return -1;
|
|---|
| 542 | *cs = *(CREATESTRUCTA *)*plparam;
|
|---|
| 543 | if (HIWORD(cs->lpszName))
|
|---|
| 544 | cs->lpszName = HEAP_strdupWtoA( GetProcessHeap(), 0,
|
|---|
| 545 | (LPCWSTR)cs->lpszName );
|
|---|
| 546 | if (HIWORD(cs->lpszClass))
|
|---|
| 547 | cs->lpszClass = HEAP_strdupWtoA( GetProcessHeap(), 0,
|
|---|
| 548 | (LPCWSTR)cs->lpszClass);
|
|---|
| 549 | *plparam = (LPARAM)cs;
|
|---|
| 550 | }
|
|---|
| 551 | return 1;
|
|---|
| 552 | case WM_MDICREATE:
|
|---|
| 553 | {
|
|---|
| 554 | MDICREATESTRUCTA *cs =
|
|---|
| 555 | (MDICREATESTRUCTA *)HeapAlloc( GetProcessHeap(), 0, sizeof(*cs) );
|
|---|
| 556 |
|
|---|
| 557 | if (!cs) return -1;
|
|---|
| 558 | *cs = *(MDICREATESTRUCTA *)*plparam;
|
|---|
| 559 | if (HIWORD(cs->szTitle))
|
|---|
| 560 | cs->szTitle = HEAP_strdupWtoA( GetProcessHeap(), 0,
|
|---|
| 561 | (LPCWSTR)cs->szTitle );
|
|---|
| 562 | if (HIWORD(cs->szClass))
|
|---|
| 563 | cs->szClass = HEAP_strdupWtoA( GetProcessHeap(), 0,
|
|---|
| 564 | (LPCWSTR)cs->szClass );
|
|---|
| 565 | *plparam = (LPARAM)cs;
|
|---|
| 566 | }
|
|---|
| 567 | return 1;
|
|---|
| 568 |
|
|---|
| 569 | /* Listbox */
|
|---|
| 570 | case LB_ADDSTRING:
|
|---|
| 571 | #ifdef __WIN32OS2__
|
|---|
| 572 | case LB_FINDSTRING:
|
|---|
| 573 | case LB_FINDSTRINGEXACT:
|
|---|
| 574 | case LB_SELECTSTRING:
|
|---|
| 575 | #endif
|
|---|
| 576 | case LB_INSERTSTRING:
|
|---|
| 577 | if ( WINPROC_TestLBForStr( hwnd ))
|
|---|
| 578 | *plparam = (LPARAM)HEAP_strdupWtoA( GetProcessHeap(), 0, (LPCWSTR)*plparam );
|
|---|
| 579 | return (*plparam ? 1 : -1);
|
|---|
| 580 |
|
|---|
| 581 | case LB_GETTEXT: /* fixme: fixed sized buffer */
|
|---|
| 582 | { if ( WINPROC_TestLBForStr( hwnd ))
|
|---|
| 583 | { LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0, 256 + sizeof(LPARAM) );
|
|---|
| 584 | if (!ptr) return -1;
|
|---|
| 585 | *ptr++ = *plparam; /* Store previous lParam */
|
|---|
| 586 | *plparam = (LPARAM)ptr;
|
|---|
| 587 | }
|
|---|
| 588 | }
|
|---|
| 589 | return 1;
|
|---|
| 590 |
|
|---|
| 591 | /* Combobox */
|
|---|
| 592 | case CB_ADDSTRING:
|
|---|
| 593 | #ifdef __WIN32OS2__
|
|---|
| 594 | case CB_FINDSTRING:
|
|---|
| 595 | case CB_FINDSTRINGEXACT:
|
|---|
| 596 | case CB_SELECTSTRING:
|
|---|
| 597 | #endif
|
|---|
| 598 | case CB_INSERTSTRING:
|
|---|
| 599 | if ( WINPROC_TestCBForStr( hwnd ))
|
|---|
| 600 | *plparam = (LPARAM)HEAP_strdupWtoA( GetProcessHeap(), 0, (LPCWSTR)*plparam );
|
|---|
| 601 | return (*plparam ? 1 : -1);
|
|---|
| 602 |
|
|---|
| 603 | case CB_GETLBTEXT: /* fixme: fixed sized buffer */
|
|---|
| 604 | { if ( WINPROC_TestCBForStr( hwnd ))
|
|---|
| 605 | { LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0, 256 + sizeof(LPARAM) );
|
|---|
| 606 | if (!ptr) return -1;
|
|---|
| 607 | *ptr++ = *plparam; /* Store previous lParam */
|
|---|
| 608 | *plparam = (LPARAM)ptr;
|
|---|
| 609 | }
|
|---|
| 610 | }
|
|---|
| 611 | return 1;
|
|---|
| 612 |
|
|---|
| 613 | /* Multiline edit */
|
|---|
| 614 | case EM_GETLINE:
|
|---|
| 615 | { WORD len = (WORD)*plparam;
|
|---|
| 616 | LPARAM *ptr = (LPARAM *) HEAP_xalloc( GetProcessHeap(), 0, sizeof(LPARAM) + sizeof (WORD) + len*sizeof(CHAR) );
|
|---|
| 617 | if (!ptr) return -1;
|
|---|
| 618 | *ptr++ = *plparam; /* Store previous lParam */
|
|---|
| 619 | *((WORD *) ptr) = len; /* Store the length */
|
|---|
| 620 | *plparam = (LPARAM)ptr;
|
|---|
| 621 | }
|
|---|
| 622 | return 1;
|
|---|
| 623 |
|
|---|
| 624 | case WM_ASKCBFORMATNAME:
|
|---|
| 625 | case WM_DEVMODECHANGE:
|
|---|
| 626 | case WM_PAINTCLIPBOARD:
|
|---|
| 627 | case WM_SIZECLIPBOARD:
|
|---|
| 628 | case EM_SETPASSWORDCHAR:
|
|---|
| 629 | // FIXME_(msg)("message %s (%04x) needs translation, please report\n",SPY_GetMsgName(msg),msg );
|
|---|
| 630 | return -1;
|
|---|
| 631 | default: /* No translation needed */
|
|---|
| 632 | return 0;
|
|---|
| 633 | }
|
|---|
| 634 | }
|
|---|
| 635 |
|
|---|
| 636 |
|
|---|
| 637 | /**********************************************************************
|
|---|
| 638 | * WINPROC_UnmapMsg32WTo32A
|
|---|
| 639 | *
|
|---|
| 640 | * Unmap a message that was mapped from Unicode to Ansi.
|
|---|
| 641 | */
|
|---|
| 642 | void WINPROC_UnmapMsg32WTo32A( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
|
|---|
| 643 | {
|
|---|
| 644 | switch(msg)
|
|---|
| 645 | {
|
|---|
| 646 | case WM_GETTEXT:
|
|---|
| 647 | {
|
|---|
| 648 | LPARAM *ptr = (LPARAM *)lParam - 1;
|
|---|
| 649 | lstrcpynAtoW( (LPWSTR)*ptr, (LPSTR)lParam, wParam );
|
|---|
| 650 | HeapFree( GetProcessHeap(), 0, ptr );
|
|---|
| 651 | }
|
|---|
| 652 | break;
|
|---|
| 653 |
|
|---|
| 654 | case WM_SETTEXT:
|
|---|
| 655 | case WM_WININICHANGE:
|
|---|
| 656 | case CB_DIR:
|
|---|
| 657 | case LB_DIR:
|
|---|
| 658 | case LB_ADDFILE:
|
|---|
| 659 | #ifndef __WIN32OS2__
|
|---|
| 660 | case CB_FINDSTRING:
|
|---|
| 661 | case CB_FINDSTRINGEXACT:
|
|---|
| 662 | case CB_SELECTSTRING:
|
|---|
| 663 | case LB_FINDSTRING:
|
|---|
| 664 | case LB_SELECTSTRING:
|
|---|
| 665 | #endif
|
|---|
| 666 | case EM_REPLACESEL:
|
|---|
| 667 | HeapFree( GetProcessHeap(), 0, (void *)lParam );
|
|---|
| 668 | break;
|
|---|
| 669 |
|
|---|
| 670 | case WM_NCCREATE:
|
|---|
| 671 | case WM_CREATE:
|
|---|
| 672 | {
|
|---|
| 673 | CREATESTRUCTA *cs = (CREATESTRUCTA *)lParam;
|
|---|
| 674 | if (HIWORD(cs->lpszName))
|
|---|
| 675 | HeapFree( GetProcessHeap(), 0, (LPVOID)cs->lpszName );
|
|---|
| 676 | if (HIWORD(cs->lpszClass))
|
|---|
| 677 | HeapFree( GetProcessHeap(), 0, (LPVOID)cs->lpszClass );
|
|---|
| 678 | HeapFree( GetProcessHeap(), 0, cs );
|
|---|
| 679 | }
|
|---|
| 680 | break;
|
|---|
| 681 |
|
|---|
| 682 | case WM_MDICREATE:
|
|---|
| 683 | {
|
|---|
| 684 | MDICREATESTRUCTA *cs = (MDICREATESTRUCTA *)lParam;
|
|---|
| 685 | if (HIWORD(cs->szTitle))
|
|---|
| 686 | HeapFree( GetProcessHeap(), 0, (LPVOID)cs->szTitle );
|
|---|
| 687 | if (HIWORD(cs->szClass))
|
|---|
| 688 | HeapFree( GetProcessHeap(), 0, (LPVOID)cs->szClass );
|
|---|
| 689 | HeapFree( GetProcessHeap(), 0, cs );
|
|---|
| 690 | }
|
|---|
| 691 | break;
|
|---|
| 692 |
|
|---|
| 693 | /* Listbox */
|
|---|
| 694 | case LB_ADDSTRING:
|
|---|
| 695 | #ifdef __WIN32OS2__
|
|---|
| 696 | case LB_FINDSTRING:
|
|---|
| 697 | case LB_FINDSTRINGEXACT:
|
|---|
| 698 | case LB_SELECTSTRING:
|
|---|
| 699 | #endif
|
|---|
| 700 | case LB_INSERTSTRING:
|
|---|
| 701 | if ( WINPROC_TestLBForStr( hwnd ))
|
|---|
| 702 | HeapFree( GetProcessHeap(), 0, (void *)lParam );
|
|---|
| 703 | break;
|
|---|
| 704 |
|
|---|
| 705 | case LB_GETTEXT:
|
|---|
| 706 | { if ( WINPROC_TestLBForStr( hwnd ))
|
|---|
| 707 | { LPARAM *ptr = (LPARAM *)lParam - 1;
|
|---|
| 708 | lstrcpyAtoW( (LPWSTR)*ptr, (LPSTR)(lParam) );
|
|---|
| 709 | HeapFree(GetProcessHeap(), 0, ptr );
|
|---|
| 710 | }
|
|---|
| 711 | }
|
|---|
| 712 | break;
|
|---|
| 713 |
|
|---|
| 714 | /* Combobox */
|
|---|
| 715 | case CB_ADDSTRING:
|
|---|
| 716 | #ifdef __WIN32OS2__
|
|---|
| 717 | case CB_FINDSTRING:
|
|---|
| 718 | case CB_FINDSTRINGEXACT:
|
|---|
| 719 | case CB_SELECTSTRING:
|
|---|
| 720 | #endif
|
|---|
| 721 | case CB_INSERTSTRING:
|
|---|
| 722 | if ( WINPROC_TestCBForStr( hwnd ))
|
|---|
| 723 | HeapFree( GetProcessHeap(), 0, (void *)lParam );
|
|---|
| 724 | break;
|
|---|
| 725 |
|
|---|
| 726 | case CB_GETLBTEXT:
|
|---|
| 727 | { if ( WINPROC_TestCBForStr( hwnd ))
|
|---|
| 728 | { LPARAM *ptr = (LPARAM *)lParam - 1;
|
|---|
| 729 | lstrcpyAtoW( (LPWSTR)*ptr, (LPSTR)(lParam) );
|
|---|
| 730 | HeapFree( GetProcessHeap(), 0, ptr );
|
|---|
| 731 | }
|
|---|
| 732 | }
|
|---|
| 733 | break;
|
|---|
| 734 |
|
|---|
| 735 | /* Multiline edit */
|
|---|
| 736 | case EM_GETLINE:
|
|---|
| 737 | { LPARAM * ptr = (LPARAM *)lParam - 1; /* get the old lparam */
|
|---|
| 738 | WORD len = *(WORD *)ptr;
|
|---|
| 739 | lstrcpynAtoW( (LPWSTR) *ptr, (LPSTR)lParam, len );
|
|---|
| 740 | HeapFree( GetProcessHeap(), 0, ptr );
|
|---|
| 741 | }
|
|---|
| 742 | break;
|
|---|
| 743 | }
|
|---|
| 744 | }
|
|---|
| 745 |
|
|---|
| 746 | /**********************************************************************
|
|---|
| 747 | * WINPROC_CallProc32ATo32W
|
|---|
| 748 | *
|
|---|
| 749 | * Call a window procedure, translating args from Ansi to Unicode.
|
|---|
| 750 | */
|
|---|
| 751 | LRESULT WINPROC_CallProc32ATo32W( WNDPROC func, HWND hwnd,
|
|---|
| 752 | UINT msg, WPARAM wParam,
|
|---|
| 753 | LPARAM lParam )
|
|---|
| 754 | {
|
|---|
| 755 | LRESULT result;
|
|---|
| 756 |
|
|---|
| 757 | if (WINPROC_MapMsg32ATo32W( hwnd, msg, wParam, &lParam ) == -1) return 0;
|
|---|
| 758 | result = func( hwnd, msg, wParam, lParam );
|
|---|
| 759 | WINPROC_UnmapMsg32ATo32W( hwnd, msg, wParam, lParam );
|
|---|
| 760 | return result;
|
|---|
| 761 | }
|
|---|
| 762 |
|
|---|
| 763 | /**********************************************************************
|
|---|
| 764 | * WINPROC_CallProc32WTo32A
|
|---|
| 765 | *
|
|---|
| 766 | * Call a window procedure, translating args from Unicode to Ansi.
|
|---|
| 767 | */
|
|---|
| 768 | LRESULT WINPROC_CallProc32WTo32A( WNDPROC func, HWND hwnd,
|
|---|
| 769 | UINT msg, WPARAM wParam,
|
|---|
| 770 | LPARAM lParam )
|
|---|
| 771 | {
|
|---|
| 772 | LRESULT result;
|
|---|
| 773 |
|
|---|
| 774 | if (WINPROC_MapMsg32WTo32A( hwnd, msg, wParam, &lParam ) == -1) return 0;
|
|---|
| 775 |
|
|---|
| 776 | result = func( hwnd, msg, wParam, lParam );
|
|---|
| 777 | WINPROC_UnmapMsg32WTo32A( hwnd, msg, wParam, lParam );
|
|---|
| 778 | return result;
|
|---|
| 779 | }
|
|---|
| 780 | //******************************************************************************
|
|---|
| 781 | //TODO: QS_HOTKEY (oslibmsg.cpp) & low word bits
|
|---|
| 782 | //high word = messages currently in queue
|
|---|
| 783 | //low word = messages that have been added to the queue and are still in the
|
|---|
| 784 | // queue since the last call to GetQueueStatus
|
|---|
| 785 | //******************************************************************************
|
|---|
| 786 | DWORD WIN32API GetQueueStatus( UINT flags)
|
|---|
| 787 | {
|
|---|
| 788 | DWORD queueStatus;
|
|---|
| 789 |
|
|---|
| 790 | queueStatus = OSLibWinQueryQueueStatus();
|
|---|
| 791 | queueStatus = MAKELONG(queueStatus, queueStatus);
|
|---|
| 792 |
|
|---|
| 793 | dprintf(("USER32: GetQueueStatus %x returned %x", flags, queueStatus & MAKELONG(flags, flags)));
|
|---|
| 794 |
|
|---|
| 795 | return queueStatus & MAKELONG(flags, flags);
|
|---|
| 796 | }
|
|---|
| 797 | /*****************************************************************************
|
|---|
| 798 | * Name : BOOL WIN32API GetInputState
|
|---|
| 799 | * Purpose : The GetInputState function determines whether there are
|
|---|
| 800 | * mouse-button or keyboard messages in the calling thread's message queue.
|
|---|
| 801 | * Parameters:
|
|---|
| 802 | * Variables :
|
|---|
| 803 | * Result : If the queue contains one or more new mouse-button or keyboard
|
|---|
| 804 | * messages, the return value is TRUE.
|
|---|
| 805 | * If the function fails, the return value is FALSE.
|
|---|
| 806 | * Remark :
|
|---|
| 807 | * Status : UNTESTED STUB
|
|---|
| 808 | *
|
|---|
| 809 | * Author : Patrick Haller [Thu, 1998/02/26 11:55]
|
|---|
| 810 | *****************************************************************************/
|
|---|
| 811 | BOOL WIN32API GetInputState(VOID)
|
|---|
| 812 | {
|
|---|
| 813 | DWORD queueStatus;
|
|---|
| 814 | BOOL rc;
|
|---|
| 815 |
|
|---|
| 816 | queueStatus = OSLibWinQueryQueueStatus();
|
|---|
| 817 |
|
|---|
| 818 | rc = (queueStatus & (QS_KEY | QS_MOUSEBUTTON)) ? TRUE : FALSE;
|
|---|
| 819 | dprintf(("USER32:GetInputState() returned %d", rc));
|
|---|
| 820 | return rc;
|
|---|
| 821 | }
|
|---|
| 822 | //******************************************************************************
|
|---|
| 823 | /* Synchronization Functions */
|
|---|
| 824 | //******************************************************************************
|
|---|
| 825 | DWORD WIN32API MsgWaitForMultipleObjects(DWORD nCount, LPHANDLE pHandles, BOOL fWaitAll,
|
|---|
| 826 | DWORD dwMilliseconds, DWORD dwWakeMask)
|
|---|
| 827 | {
|
|---|
| 828 | DWORD curtime, endtime, ret;
|
|---|
| 829 | MSG msg;
|
|---|
| 830 |
|
|---|
| 831 | dprintf(("MsgWaitForMultipleObjects %x %x %d %d %x", nCount, pHandles, fWaitAll, dwMilliseconds, dwWakeMask));
|
|---|
| 832 | // @@@PH this is a temporary bugfix for WINFILE.EXE
|
|---|
| 833 | if (nCount == 0)
|
|---|
| 834 | {
|
|---|
| 835 | if(dwMilliseconds == 0) {
|
|---|
| 836 | if(GetQueueStatus(dwWakeMask) == 0) {
|
|---|
| 837 | return WAIT_TIMEOUT;
|
|---|
| 838 | }
|
|---|
| 839 | return WAIT_OBJECT_0;
|
|---|
| 840 | }
|
|---|
| 841 | //SvL: Check time, wait for any message, check msg type and determine if
|
|---|
| 842 | // we have to return
|
|---|
| 843 | //TODO: Timeout isn't handled correctly (can return too late)
|
|---|
| 844 | curtime = GetCurrentTime();
|
|---|
| 845 | endtime = curtime + dwMilliseconds;
|
|---|
| 846 | while(curtime < endtime || dwMilliseconds == INFINITE) {
|
|---|
| 847 | if(OSLibWinWaitMessage() == FALSE) {
|
|---|
| 848 | dprintf(("OSLibWinWaitMessage returned FALSE!"));
|
|---|
| 849 | return WAIT_ABANDONED;
|
|---|
| 850 | }
|
|---|
| 851 | if(GetQueueStatus(dwWakeMask) != 0) {
|
|---|
| 852 | return WAIT_OBJECT_0;
|
|---|
| 853 | }
|
|---|
| 854 | //TODO: Ignoring all messages could be dangerous. But processing them,
|
|---|
| 855 | //while the app doesn't expect any, isn't safe either.
|
|---|
| 856 | if(PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE))
|
|---|
| 857 | {
|
|---|
| 858 | if (msg.message == WM_QUIT) {
|
|---|
| 859 | dprintf(("ERROR: MsgWaitForMultipleObjects call abandoned because WM_QUIT msg was received!!"));
|
|---|
| 860 | return WAIT_ABANDONED;
|
|---|
| 861 | }
|
|---|
| 862 |
|
|---|
| 863 | /* otherwise dispatch it */
|
|---|
| 864 | DispatchMessageA(&msg);
|
|---|
| 865 | }
|
|---|
| 866 | curtime = GetCurrentTime();
|
|---|
| 867 | }
|
|---|
| 868 | return WAIT_TIMEOUT;
|
|---|
| 869 | }
|
|---|
| 870 | //Call handlemanager function as we need to translate handles (KERNEL32)
|
|---|
| 871 | ret = HMMsgWaitForMultipleObjects(nCount,pHandles,fWaitAll,dwMilliseconds,dwWakeMask);
|
|---|
| 872 | return ret;
|
|---|
| 873 | }
|
|---|