| 1 | /* $Id: windowmsg.cpp,v 1.30 2001-09-27 10:42:59 phaller Exp $ */ | 
|---|
| 2 | /* | 
|---|
| 3 | * Win32 window message APIs for OS/2 | 
|---|
| 4 | * | 
|---|
| 5 | * Copyright 1999 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 | VOID WIN32API PostQuitMessage( int nExitCode) | 
|---|
| 42 | { | 
|---|
| 43 | dprintf(("USER32:  PostQuitMessage\n")); | 
|---|
| 44 | OSLibWinPostQuitMessage(nExitCode); | 
|---|
| 45 | } | 
|---|
| 46 | //****************************************************************************** | 
|---|
| 47 | //****************************************************************************** | 
|---|
| 48 | LONG WIN32API DispatchMessageA(const MSG * msg) | 
|---|
| 49 | { | 
|---|
| 50 | dprintf2(("DispatchMessageA %x %x %x %x %x", msg->hwnd, msg->message, msg->wParam, msg->lParam, msg->time)); | 
|---|
| 51 | return OSLibWinDispatchMsg((MSG *)msg); | 
|---|
| 52 | } | 
|---|
| 53 | //****************************************************************************** | 
|---|
| 54 | //****************************************************************************** | 
|---|
| 55 | LONG WIN32API DispatchMessageW( const MSG * msg) | 
|---|
| 56 | { | 
|---|
| 57 | dprintf2(("DispatchMessageW %x %x %x %x %x", msg->hwnd, msg->message, msg->wParam, msg->lParam, msg->time)); | 
|---|
| 58 | return OSLibWinDispatchMsg((MSG *)msg, TRUE); | 
|---|
| 59 | } | 
|---|
| 60 | //****************************************************************************** | 
|---|
| 61 | //****************************************************************************** | 
|---|
| 62 | BOOL WIN32API TranslateMessage(const MSG *msg) | 
|---|
| 63 | { | 
|---|
| 64 | // check the message code | 
|---|
| 65 | if ( (msg->message <  WM_KEYDOWN) || | 
|---|
| 66 | (msg->message >  WM_SYSKEYUP)|| | 
|---|
| 67 | (msg->message == WM_CHAR)    || | 
|---|
| 68 | (msg->message == WM_DEADCHAR) ) | 
|---|
| 69 | { | 
|---|
| 70 | SetLastError(ERROR_INVALID_PARAMETER); | 
|---|
| 71 | return FALSE; | 
|---|
| 72 | } | 
|---|
| 73 |  | 
|---|
| 74 | // only WM_KEYDOWN, WM_KEYUP, WM_SYSKEYDOWN, WM_SYSKEYUP | 
|---|
| 75 | // can go into TranslateMessage | 
|---|
| 76 |  | 
|---|
| 77 | return OSLibWinTranslateMessage((MSG *)msg); | 
|---|
| 78 | } | 
|---|
| 79 | //****************************************************************************** | 
|---|
| 80 | //****************************************************************************** | 
|---|
| 81 | BOOL WIN32API GetMessageA( LPMSG pMsg, HWND hwnd, UINT uMsgFilterMin, UINT uMsgFilterMax) | 
|---|
| 82 | { | 
|---|
| 83 | BOOL ret; | 
|---|
| 84 |  | 
|---|
| 85 | dprintf2(("GetMessageA %x %x-%x", hwnd, uMsgFilterMin, uMsgFilterMax)); | 
|---|
| 86 | ret = OSLibWinGetMsg(pMsg, hwnd, uMsgFilterMin, uMsgFilterMax); | 
|---|
| 87 | if(ret) dprintf2(("GetMessageA %x %x %x %x", hwnd, pMsg->message, pMsg->wParam, pMsg->lParam)); | 
|---|
| 88 | HOOK_CallHooksA(WH_GETMESSAGE, HC_ACTION, PM_REMOVE, (LPARAM)pMsg); | 
|---|
| 89 | return ret; | 
|---|
| 90 | } | 
|---|
| 91 | //****************************************************************************** | 
|---|
| 92 | //****************************************************************************** | 
|---|
| 93 | BOOL WIN32API GetMessageW( LPMSG pMsg, HWND hwnd, UINT uMsgFilterMin, UINT uMsgFilterMax) | 
|---|
| 94 | { | 
|---|
| 95 | BOOL ret; | 
|---|
| 96 |  | 
|---|
| 97 | dprintf2(("GetMessageW %x %x-%x", hwnd, uMsgFilterMin, uMsgFilterMax)); | 
|---|
| 98 | ret = OSLibWinGetMsg(pMsg, hwnd, uMsgFilterMin, uMsgFilterMax, TRUE); | 
|---|
| 99 | HOOK_CallHooksW(WH_GETMESSAGE, HC_ACTION, PM_REMOVE, (LPARAM)pMsg); | 
|---|
| 100 | return ret; | 
|---|
| 101 | } | 
|---|
| 102 | //****************************************************************************** | 
|---|
| 103 | //****************************************************************************** | 
|---|
| 104 | BOOL WIN32API PeekMessageA(LPMSG msg, HWND hwndOwner, UINT uMsgFilterMin, | 
|---|
| 105 | UINT uMsgFilterMax, UINT fuRemoveMsg) | 
|---|
| 106 | { | 
|---|
| 107 | BOOL fFoundMsg; | 
|---|
| 108 |  | 
|---|
| 109 | dprintf2(("PeekMessageA %x %d-%d %d", hwndOwner, uMsgFilterMin, uMsgFilterMax, fuRemoveMsg)); | 
|---|
| 110 | fFoundMsg = OSLibWinPeekMsg(msg, hwndOwner, uMsgFilterMin, uMsgFilterMax, | 
|---|
| 111 | fuRemoveMsg, FALSE); | 
|---|
| 112 | if(fFoundMsg) { | 
|---|
| 113 | dprintf2(("PeekMessageA %x %d-%d %d found message %x %d %x %x", hwndOwner, uMsgFilterMin, uMsgFilterMax, fuRemoveMsg, msg->hwnd, msg->message, msg->wParam, msg->lParam)); | 
|---|
| 114 | HOOK_CallHooksA(WH_GETMESSAGE, HC_ACTION, fuRemoveMsg & PM_REMOVE, (LPARAM)msg ); | 
|---|
| 115 | if (msg->message == WM_QUIT && (fuRemoveMsg & PM_REMOVE)) { | 
|---|
| 116 | //TODO: Post WM_QUERYENDSESSION message when WM_QUIT received and system is shutting down | 
|---|
| 117 | } | 
|---|
| 118 | } | 
|---|
| 119 | return fFoundMsg; | 
|---|
| 120 | } | 
|---|
| 121 | //****************************************************************************** | 
|---|
| 122 | //****************************************************************************** | 
|---|
| 123 | BOOL WIN32API PeekMessageW(LPMSG msg, HWND hwndOwner, UINT uMsgFilterMin, | 
|---|
| 124 | UINT uMsgFilterMax, UINT fuRemoveMsg) | 
|---|
| 125 | { | 
|---|
| 126 | BOOL fFoundMsg; | 
|---|
| 127 |  | 
|---|
| 128 | dprintf2(("PeekMessageW %x %d-%d %d", hwndOwner, uMsgFilterMin, uMsgFilterMax, fuRemoveMsg)); | 
|---|
| 129 | fFoundMsg = OSLibWinPeekMsg(msg, hwndOwner, uMsgFilterMin, uMsgFilterMax, | 
|---|
| 130 | fuRemoveMsg, TRUE); | 
|---|
| 131 | if(fFoundMsg) { | 
|---|
| 132 | dprintf2(("PeekMessageW %x %d-%d %d found message %x %d %x %x", hwndOwner, uMsgFilterMin, uMsgFilterMax, fuRemoveMsg, msg->hwnd, msg->message, msg->wParam, msg->lParam)); | 
|---|
| 133 | HOOK_CallHooksW(WH_GETMESSAGE, HC_ACTION, fuRemoveMsg & PM_REMOVE, (LPARAM)msg ); | 
|---|
| 134 | if (msg->message == WM_QUIT && (fuRemoveMsg & (PM_REMOVE))) { | 
|---|
| 135 | //TODO: Post WM_QUERYENDSESSION message when WM_QUIT received and system is shutting down | 
|---|
| 136 | } | 
|---|
| 137 | } | 
|---|
| 138 | return fFoundMsg; | 
|---|
| 139 | } | 
|---|
| 140 | //****************************************************************************** | 
|---|
| 141 | //TODO: | 
|---|
| 142 | //****************************************************************************** | 
|---|
| 143 | LONG WIN32API GetMessageExtraInfo() | 
|---|
| 144 | { | 
|---|
| 145 | dprintf(("USER32: GetMessageExtraInfo")); | 
|---|
| 146 | return GetThreadMessageExtraInfo(); | 
|---|
| 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 | LRESULT WIN32API SendMessageA(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) | 
|---|
| 168 | { | 
|---|
| 169 | Win32BaseWindow *window; | 
|---|
| 170 | LRESULT result; | 
|---|
| 171 |  | 
|---|
| 172 | if (hwnd == HWND_BROADCAST|| hwnd == HWND_TOPMOST) | 
|---|
| 173 | { | 
|---|
| 174 | Win32BaseWindow::BroadcastMessageA(BROADCAST_SEND, msg, wParam, lParam); | 
|---|
| 175 | return TRUE; | 
|---|
| 176 | } | 
|---|
| 177 |  | 
|---|
| 178 | window = Win32BaseWindow::GetWindowFromHandle(hwnd); | 
|---|
| 179 | if(!window) { | 
|---|
| 180 | dprintf(("SendMessageA, %x %x %x window %x not found", msg, wParam, lParam, hwnd)); | 
|---|
| 181 | return 0; | 
|---|
| 182 | } | 
|---|
| 183 | result = window->SendMessageA(msg, wParam, lParam); | 
|---|
| 184 | RELEASE_WNDOBJ(window); | 
|---|
| 185 | return result; | 
|---|
| 186 | } | 
|---|
| 187 | //****************************************************************************** | 
|---|
| 188 | //****************************************************************************** | 
|---|
| 189 | LRESULT WIN32API SendMessageW(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) | 
|---|
| 190 | { | 
|---|
| 191 | Win32BaseWindow *window; | 
|---|
| 192 | LRESULT result; | 
|---|
| 193 |  | 
|---|
| 194 | if (hwnd == HWND_BROADCAST|| hwnd == HWND_TOPMOST) | 
|---|
| 195 | { | 
|---|
| 196 | Win32BaseWindow::BroadcastMessageW(BROADCAST_SEND, msg, wParam, lParam); | 
|---|
| 197 | return TRUE; | 
|---|
| 198 | } | 
|---|
| 199 |  | 
|---|
| 200 | window = Win32BaseWindow::GetWindowFromHandle(hwnd); | 
|---|
| 201 | if(!window) { | 
|---|
| 202 | dprintf(("SendMessageW, window %x not found", hwnd)); | 
|---|
| 203 | return 0; | 
|---|
| 204 | } | 
|---|
| 205 | result = window->SendMessageW(msg, wParam, lParam); | 
|---|
| 206 | RELEASE_WNDOBJ(window); | 
|---|
| 207 | return result; | 
|---|
| 208 | } | 
|---|
| 209 | //****************************************************************************** | 
|---|
| 210 | //****************************************************************************** | 
|---|
| 211 | BOOL WIN32API PostMessageA(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) | 
|---|
| 212 | { | 
|---|
| 213 | Win32BaseWindow *window; | 
|---|
| 214 | HWND hwndOS2; | 
|---|
| 215 |  | 
|---|
| 216 | if (hwnd == HWND_BROADCAST) //Not HWND_TOPMOST??? | 
|---|
| 217 | { | 
|---|
| 218 | Win32BaseWindow::BroadcastMessageA(BROADCAST_POST, msg, wParam, lParam); | 
|---|
| 219 | return TRUE; | 
|---|
| 220 | } | 
|---|
| 221 |  | 
|---|
| 222 | if(hwnd == NULL) | 
|---|
| 223 | return PostThreadMessageA(GetCurrentThreadId(), msg, wParam, lParam); | 
|---|
| 224 |  | 
|---|
| 225 | window = Win32BaseWindow::GetWindowFromHandle(hwnd); | 
|---|
| 226 | if(!window) { | 
|---|
| 227 | dprintf(("PostMessageA, window %x not found", hwnd)); | 
|---|
| 228 | return FALSE; | 
|---|
| 229 | } | 
|---|
| 230 | hwndOS2 = window->getOS2WindowHandle(); | 
|---|
| 231 | RELEASE_WNDOBJ(window); | 
|---|
| 232 | dprintf(("PostMessageA, %x %x %x %x", hwnd, msg, wParam, lParam)); | 
|---|
| 233 | return OSLibPostMessage(hwndOS2, msg, wParam, lParam, FALSE); | 
|---|
| 234 | } | 
|---|
| 235 | //****************************************************************************** | 
|---|
| 236 | //****************************************************************************** | 
|---|
| 237 | BOOL WIN32API PostMessageW(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) | 
|---|
| 238 | { | 
|---|
| 239 | Win32BaseWindow *window; | 
|---|
| 240 | HWND hwndOS2; | 
|---|
| 241 |  | 
|---|
| 242 | if (hwnd == HWND_BROADCAST) //Not HWND_TOPMOST??? | 
|---|
| 243 | { | 
|---|
| 244 | Win32BaseWindow::BroadcastMessageW(BROADCAST_POST, msg, wParam, lParam); | 
|---|
| 245 | return TRUE; | 
|---|
| 246 | } | 
|---|
| 247 |  | 
|---|
| 248 | if(hwnd == NULL) | 
|---|
| 249 | return PostThreadMessageW(GetCurrentThreadId(), msg, wParam, lParam); | 
|---|
| 250 |  | 
|---|
| 251 | window = Win32BaseWindow::GetWindowFromHandle(hwnd); | 
|---|
| 252 | if(!window) { | 
|---|
| 253 | dprintf(("PostMessageW, window %x not found", hwnd)); | 
|---|
| 254 | return FALSE; | 
|---|
| 255 | } | 
|---|
| 256 | hwndOS2 = window->getOS2WindowHandle(); | 
|---|
| 257 | RELEASE_WNDOBJ(window); | 
|---|
| 258 | dprintf(("PostMessageW, %x %x %x %x", hwnd, msg, wParam, lParam)); | 
|---|
| 259 | return OSLibPostMessage(hwndOS2, msg, wParam, lParam, TRUE); | 
|---|
| 260 | } | 
|---|
| 261 | //****************************************************************************** | 
|---|
| 262 | //****************************************************************************** | 
|---|
| 263 | BOOL WIN32API PostThreadMessageA( DWORD threadid, UINT msg, WPARAM wParam, LPARAM lParam) | 
|---|
| 264 | { | 
|---|
| 265 | return OSLibPostThreadMessage(threadid, msg, wParam, lParam, FALSE); | 
|---|
| 266 | } | 
|---|
| 267 | //****************************************************************************** | 
|---|
| 268 | //****************************************************************************** | 
|---|
| 269 | BOOL WIN32API PostThreadMessageW( DWORD threadid, UINT msg, WPARAM wParam, LPARAM lParam) | 
|---|
| 270 | { | 
|---|
| 271 | return OSLibPostThreadMessage(threadid, msg, wParam, lParam, TRUE); | 
|---|
| 272 | } | 
|---|
| 273 | //****************************************************************************** | 
|---|
| 274 | //****************************************************************************** | 
|---|
| 275 | BOOL WIN32API WaitMessage(void) | 
|---|
| 276 | { | 
|---|
| 277 | dprintf2(("USER32: WaitMessage")); | 
|---|
| 278 | return OSLibWinWaitMessage(); | 
|---|
| 279 | } | 
|---|
| 280 | //****************************************************************************** | 
|---|
| 281 | //****************************************************************************** | 
|---|
| 282 | BOOL WIN32API InSendMessage(void) | 
|---|
| 283 | { | 
|---|
| 284 | dprintf(("USER32:  InSendMessage")); | 
|---|
| 285 | return OSLibWinInSendMessage(); | 
|---|
| 286 | } | 
|---|
| 287 | //****************************************************************************** | 
|---|
| 288 | //****************************************************************************** | 
|---|
| 289 | BOOL WIN32API ReplyMessage(LRESULT result) | 
|---|
| 290 | { | 
|---|
| 291 | dprintf(("USER32: ReplyMessage %x", result)); | 
|---|
| 292 | return OSLibWinReplyMessage(result); | 
|---|
| 293 | } | 
|---|
| 294 | //****************************************************************************** | 
|---|
| 295 | //****************************************************************************** | 
|---|
| 296 | UINT WIN32API RegisterWindowMessageA(LPCSTR lpString) | 
|---|
| 297 | { | 
|---|
| 298 | UINT rc; | 
|---|
| 299 |  | 
|---|
| 300 | rc = GlobalAddAtomA(lpString); | 
|---|
| 301 | dprintf(("USER32:  RegisterWindowMessageA %s returned %X\n", lpString, rc)); | 
|---|
| 302 | return(rc); | 
|---|
| 303 | } | 
|---|
| 304 | //****************************************************************************** | 
|---|
| 305 | //****************************************************************************** | 
|---|
| 306 | UINT WIN32API RegisterWindowMessageW( LPCWSTR lpString) | 
|---|
| 307 | { | 
|---|
| 308 | dprintf(("USER32:  RegisterWindowMessageW\n")); | 
|---|
| 309 | return GlobalAddAtomW(lpString); | 
|---|
| 310 | } | 
|---|
| 311 | //****************************************************************************** | 
|---|
| 312 | //No need to support this (obsolete, not implemented by Win32) | 
|---|
| 313 | //****************************************************************************** | 
|---|
| 314 | BOOL WIN32API SetMessageQueue(int cMessagesMax) | 
|---|
| 315 | { | 
|---|
| 316 | dprintf(("USER32:  SetMessageQueue\n")); | 
|---|
| 317 | return(TRUE); | 
|---|
| 318 | } | 
|---|
| 319 | //****************************************************************************** | 
|---|
| 320 | //****************************************************************************** | 
|---|
| 321 | LRESULT WIN32API SendMessageTimeoutA(HWND hwnd, UINT Msg, WPARAM wParam, | 
|---|
| 322 | LPARAM lParam, UINT fuFlags, UINT uTimeOut, | 
|---|
| 323 | LPDWORD lpdwResult) | 
|---|
| 324 | { | 
|---|
| 325 | dprintf(("USER32:  SendMessageTimeoutA, partially implemented\n")); | 
|---|
| 326 | //ignore fuFlags & wTimeOut | 
|---|
| 327 | *lpdwResult = SendMessageA(hwnd, Msg, wParam, lParam); | 
|---|
| 328 | return(TRUE); | 
|---|
| 329 | } | 
|---|
| 330 | //****************************************************************************** | 
|---|
| 331 | //****************************************************************************** | 
|---|
| 332 | LRESULT WIN32API SendMessageTimeoutW(HWND hwnd, UINT Msg, WPARAM wParam, | 
|---|
| 333 | LPARAM lParam, UINT fuFlags, UINT uTimeOut, | 
|---|
| 334 | LPDWORD lpdwResult) | 
|---|
| 335 | { | 
|---|
| 336 | dprintf(("USER32:  SendMessageTimeoutW, partially implemented\n")); | 
|---|
| 337 | return(SendMessageTimeoutA(hwnd, Msg, wParam, lParam, fuFlags, uTimeOut, lpdwResult)); | 
|---|
| 338 | } | 
|---|
| 339 | //****************************************************************************** | 
|---|
| 340 | //****************************************************************************** | 
|---|
| 341 | BOOL WIN32API SendNotifyMessageA(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam) | 
|---|
| 342 | { | 
|---|
| 343 | dprintf(("USER32:  SendNotifyMessageA, not completely implemented\n")); | 
|---|
| 344 | return(SendMessageA(hwnd, Msg, wParam, lParam)); | 
|---|
| 345 | } | 
|---|
| 346 | //****************************************************************************** | 
|---|
| 347 | //****************************************************************************** | 
|---|
| 348 | BOOL WIN32API SendNotifyMessageW(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam) | 
|---|
| 349 | { | 
|---|
| 350 | dprintf(("USER32:  SendNotifyMessageW, not completely implemented\n")); | 
|---|
| 351 | return(SendMessageA(hwnd, Msg, wParam, lParam)); | 
|---|
| 352 | } | 
|---|
| 353 | //****************************************************************************** | 
|---|
| 354 | //****************************************************************************** | 
|---|
| 355 | LPARAM WIN32API SetMessageExtraInfo(LPARAM lParam) | 
|---|
| 356 | { | 
|---|
| 357 | dprintf(("USER32:  SetMessageExtraInfo\n")); | 
|---|
| 358 | return SetThreadMessageExtraInfo(lParam); | 
|---|
| 359 | } | 
|---|
| 360 | /***************************************************************************** | 
|---|
| 361 | * Name      : BOOL WIN32API SendMessageCallbackA | 
|---|
| 362 | * Purpose   : The SendMessageCallback function sends the specified message to | 
|---|
| 363 | *             a window or windows. The function calls the window procedure for | 
|---|
| 364 | *             the specified window and returns immediately. After the window | 
|---|
| 365 | *             procedure processes the message, the system calls the specified | 
|---|
| 366 | *             callback function, passing the result of the message processing | 
|---|
| 367 | *             and an application-defined value to the callback function. | 
|---|
| 368 | * Parameters: HWND  hwnd                      handle of destination window | 
|---|
| 369 | *             UINT  uMsg                      message to send | 
|---|
| 370 | *             WPARAM  wParam                  first message parameter | 
|---|
| 371 | *             LPARAM  lParam                  second message parameter | 
|---|
| 372 | *             SENDASYNCPROC  lpResultCallBack function to receive message value | 
|---|
| 373 | *             DWORD  dwData                   value to pass to callback function | 
|---|
| 374 | * Variables : | 
|---|
| 375 | * Result    : If the function succeeds, the return value is TRUE. | 
|---|
| 376 | *             If the function fails, the return value is FALSE. To get extended | 
|---|
| 377 | *             error information, call GetLastError. | 
|---|
| 378 | * Remark    : | 
|---|
| 379 | * Status    : UNTESTED STUB | 
|---|
| 380 | * | 
|---|
| 381 | * Author    : Patrick Haller [Thu, 1998/02/26 11:55] | 
|---|
| 382 | *****************************************************************************/ | 
|---|
| 383 |  | 
|---|
| 384 | BOOL WIN32API SendMessageCallbackA(HWND          hWnd, | 
|---|
| 385 | UINT          uMsg, | 
|---|
| 386 | WPARAM        wParam, | 
|---|
| 387 | LPARAM        lParam, | 
|---|
| 388 | SENDASYNCPROC lpResultCallBack, | 
|---|
| 389 | DWORD         dwData) | 
|---|
| 390 | { | 
|---|
| 391 | dprintf(("USER32:SendMessageCallBackA (%08xh,%08xh,%08xh,%08xh,%08xh,%08x) not implemented.\n", | 
|---|
| 392 | hWnd, | 
|---|
| 393 | uMsg, | 
|---|
| 394 | wParam, | 
|---|
| 395 | lParam, | 
|---|
| 396 | lpResultCallBack, | 
|---|
| 397 | dwData)); | 
|---|
| 398 |  | 
|---|
| 399 | return (FALSE); | 
|---|
| 400 | } | 
|---|
| 401 |  | 
|---|
| 402 |  | 
|---|
| 403 | /***************************************************************************** | 
|---|
| 404 | * Name      : BOOL WIN32API SendMessageCallbackW | 
|---|
| 405 | * Purpose   : The SendMessageCallback function sends the specified message to | 
|---|
| 406 | *             a window or windows. The function calls the window procedure for | 
|---|
| 407 | *             the specified window and returns immediately. After the window | 
|---|
| 408 | *             procedure processes the message, the system calls the specified | 
|---|
| 409 | *             callback function, passing the result of the message processing | 
|---|
| 410 | *             and an application-defined value to the callback function. | 
|---|
| 411 | * Parameters: HWND  hwnd                      handle of destination window | 
|---|
| 412 | *             UINT  uMsg                      message to send | 
|---|
| 413 | *             WPARAM  wParam                  first message parameter | 
|---|
| 414 | *             LPARAM  lParam                  second message parameter | 
|---|
| 415 | *             SENDASYNCPROC  lpResultCallBack function to receive message value | 
|---|
| 416 | *             DWORD  dwData                   value to pass to callback function | 
|---|
| 417 | * Variables : | 
|---|
| 418 | * Result    : If the function succeeds, the return value is TRUE. | 
|---|
| 419 | *             If the function fails, the return value is FALSE. To get extended | 
|---|
| 420 | *             error information, call GetLastError. | 
|---|
| 421 | * Remark    : | 
|---|
| 422 | * Status    : UNTESTED STUB | 
|---|
| 423 | * | 
|---|
| 424 | * Author    : Patrick Haller [Thu, 1998/02/26 11:55] | 
|---|
| 425 | *****************************************************************************/ | 
|---|
| 426 |  | 
|---|
| 427 | BOOL WIN32API SendMessageCallbackW(HWND          hWnd, | 
|---|
| 428 | UINT          uMsg, | 
|---|
| 429 | WPARAM        wParam, | 
|---|
| 430 | LPARAM        lParam, | 
|---|
| 431 | SENDASYNCPROC lpResultCallBack, | 
|---|
| 432 | DWORD         dwData) | 
|---|
| 433 | { | 
|---|
| 434 | dprintf(("USER32:SendMessageCallBackW (%08xh,%08xh,%08xh,%08xh,%08xh,%08x) not implemented.\n", | 
|---|
| 435 | hWnd, | 
|---|
| 436 | uMsg, | 
|---|
| 437 | wParam, | 
|---|
| 438 | lParam, | 
|---|
| 439 | lpResultCallBack, | 
|---|
| 440 | dwData)); | 
|---|
| 441 |  | 
|---|
| 442 | return (FALSE); | 
|---|
| 443 | } | 
|---|
| 444 | /***************************************************************************** | 
|---|
| 445 | * Name      : long WIN32API BroadcastSystemMessage | 
|---|
| 446 | * Purpose   : The BroadcastSystemMessage function sends a message to the given | 
|---|
| 447 | *             recipients. The recipients can be applications, installable | 
|---|
| 448 | *             drivers, Windows-based network drivers, system-level device | 
|---|
| 449 | *             drivers, or any combination of these system components. | 
|---|
| 450 | * Parameters: DWORD   dwFlags, | 
|---|
| 451 | LPDWORD lpdwRecipients, | 
|---|
| 452 | UINT    uiMessage, | 
|---|
| 453 | WPARAM  wParam, | 
|---|
| 454 | LPARAM  lParam | 
|---|
| 455 | * Variables : | 
|---|
| 456 | * Result    : If the function succeeds, the return value is a positive value. | 
|---|
| 457 | *             If the function is unable to broadcast the message, the return value is -1. | 
|---|
| 458 | *             If the dwFlags parameter is BSF_QUERY and at least one recipient returned FALSE to the corresponding message, the return value is zero. | 
|---|
| 459 | * Remark    : | 
|---|
| 460 | * Status    : UNTESTED STUB | 
|---|
| 461 | * | 
|---|
| 462 | * Author    : Patrick Haller [Thu, 1998/02/26 11:55] | 
|---|
| 463 | *****************************************************************************/ | 
|---|
| 464 |  | 
|---|
| 465 | long WIN32API BroadcastSystemMessage(DWORD   dwFlags, | 
|---|
| 466 | LPDWORD lpdwRecipients, | 
|---|
| 467 | UINT    uiMessage, | 
|---|
| 468 | WPARAM  wParam, | 
|---|
| 469 | LPARAM  lParam) | 
|---|
| 470 | { | 
|---|
| 471 | dprintf(("USER32:BroadcastSystemMessage(%08xh,%08xh,%08xh,%08xh,%08x) not implemented.\n", | 
|---|
| 472 | dwFlags, | 
|---|
| 473 | lpdwRecipients, | 
|---|
| 474 | uiMessage, | 
|---|
| 475 | wParam, | 
|---|
| 476 | lParam)); | 
|---|
| 477 |  | 
|---|
| 478 | return (-1); | 
|---|
| 479 | } | 
|---|
| 480 | //****************************************************************************** | 
|---|
| 481 | //****************************************************************************** | 
|---|
| 482 | /********************************************************************** | 
|---|
| 483 | *           WINPROC_TestCBForStr | 
|---|
| 484 | * | 
|---|
| 485 | * Return TRUE if the lparam is a string | 
|---|
| 486 | */ | 
|---|
| 487 | BOOL WINPROC_TestCBForStr ( HWND hwnd ) | 
|---|
| 488 | { | 
|---|
| 489 | BOOL retvalue; | 
|---|
| 490 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); | 
|---|
| 491 | retvalue = ( !(LOWORD(dwStyle) & (CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE)) || | 
|---|
| 492 | (LOWORD(dwStyle) & CBS_HASSTRINGS) ); | 
|---|
| 493 | return retvalue; | 
|---|
| 494 | } | 
|---|
| 495 | /********************************************************************** | 
|---|
| 496 | *           WINPROC_TestLBForStr | 
|---|
| 497 | * | 
|---|
| 498 | * Return TRUE if the lparam is a string | 
|---|
| 499 | */ | 
|---|
| 500 | BOOL WINPROC_TestLBForStr ( HWND hwnd ) | 
|---|
| 501 | { | 
|---|
| 502 | BOOL retvalue; | 
|---|
| 503 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); | 
|---|
| 504 | retvalue = ( !(LOWORD(dwStyle) & (LBS_OWNERDRAWFIXED | LBS_OWNERDRAWVARIABLE)) || | 
|---|
| 505 | (LOWORD(dwStyle) & LBS_HASSTRINGS) ); | 
|---|
| 506 | return retvalue; | 
|---|
| 507 | } | 
|---|
| 508 |  | 
|---|
| 509 | /********************************************************************** | 
|---|
| 510 | *           WINPROC_MapMsg32ATo32W | 
|---|
| 511 | * | 
|---|
| 512 | * Map a message from Ansi to Unicode. | 
|---|
| 513 | * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed. | 
|---|
| 514 | * | 
|---|
| 515 | * FIXME: | 
|---|
| 516 | *  WM_CHAR, WM_CHARTOITEM, WM_DEADCHAR, WM_MENUCHAR, WM_SYSCHAR, WM_SYSDEADCHAR | 
|---|
| 517 | * | 
|---|
| 518 | * FIXME: | 
|---|
| 519 | *  WM_GETTEXT/WM_SETTEXT and static control with SS_ICON style: | 
|---|
| 520 | *  the first four bytes are the handle of the icon | 
|---|
| 521 | *  when the WM_SETTEXT message has been used to set the icon | 
|---|
| 522 | */ | 
|---|
| 523 | INT WINPROC_MapMsg32ATo32W( HWND hwnd, UINT msg, WPARAM wParam, LPARAM *plparam ) | 
|---|
| 524 | { | 
|---|
| 525 | switch(msg) | 
|---|
| 526 | { | 
|---|
| 527 | case WM_GETTEXT: | 
|---|
| 528 | { | 
|---|
| 529 | LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0, | 
|---|
| 530 | wParam * sizeof(WCHAR) + sizeof(LPARAM) ); | 
|---|
| 531 | if (!ptr) return -1; | 
|---|
| 532 | *ptr++ = *plparam;  /* Store previous lParam */ | 
|---|
| 533 | *plparam = (LPARAM)ptr; | 
|---|
| 534 | } | 
|---|
| 535 | return 1; | 
|---|
| 536 | /* lparam is string (0-terminated) */ | 
|---|
| 537 | case WM_SETTEXT: | 
|---|
| 538 | case WM_WININICHANGE: | 
|---|
| 539 | case CB_DIR: | 
|---|
| 540 | case LB_DIR: | 
|---|
| 541 | case LB_ADDFILE: | 
|---|
| 542 | #ifndef __WIN32OS2__ | 
|---|
| 543 | case CB_FINDSTRING: | 
|---|
| 544 | case CB_FINDSTRINGEXACT: | 
|---|
| 545 | case CB_SELECTSTRING: | 
|---|
| 546 | case LB_FINDSTRING: | 
|---|
| 547 | case LB_SELECTSTRING: | 
|---|
| 548 | #endif | 
|---|
| 549 | case EM_REPLACESEL: | 
|---|
| 550 | *plparam = (LPARAM)HEAP_strdupAtoW( GetProcessHeap(), 0, (LPCSTR)*plparam ); | 
|---|
| 551 | return (*plparam ? 1 : -1); | 
|---|
| 552 |  | 
|---|
| 553 | case WM_NCCREATE: | 
|---|
| 554 | case WM_CREATE: | 
|---|
| 555 | { | 
|---|
| 556 | CREATESTRUCTW *cs = (CREATESTRUCTW *)HeapAlloc( GetProcessHeap(), 0, | 
|---|
| 557 | sizeof(*cs) ); | 
|---|
| 558 | if (!cs) return -1; | 
|---|
| 559 | *cs = *(CREATESTRUCTW *)*plparam; | 
|---|
| 560 | if (HIWORD(cs->lpszName)) | 
|---|
| 561 | cs->lpszName = HEAP_strdupAtoW( GetProcessHeap(), 0, | 
|---|
| 562 | (LPCSTR)cs->lpszName ); | 
|---|
| 563 | if (HIWORD(cs->lpszClass)) | 
|---|
| 564 | cs->lpszClass = HEAP_strdupAtoW( GetProcessHeap(), 0, | 
|---|
| 565 | (LPCSTR)cs->lpszClass ); | 
|---|
| 566 | *plparam = (LPARAM)cs; | 
|---|
| 567 | } | 
|---|
| 568 | return 1; | 
|---|
| 569 | case WM_MDICREATE: | 
|---|
| 570 | { | 
|---|
| 571 | MDICREATESTRUCTW *cs = | 
|---|
| 572 | (MDICREATESTRUCTW *)HeapAlloc( GetProcessHeap(), 0, sizeof(*cs) ); | 
|---|
| 573 | if (!cs) return -1; | 
|---|
| 574 | *cs = *(MDICREATESTRUCTW *)*plparam; | 
|---|
| 575 | if (HIWORD(cs->szClass)) | 
|---|
| 576 | cs->szClass = HEAP_strdupAtoW( GetProcessHeap(), 0, | 
|---|
| 577 | (LPCSTR)cs->szClass ); | 
|---|
| 578 | if (HIWORD(cs->szTitle)) | 
|---|
| 579 | cs->szTitle = HEAP_strdupAtoW( GetProcessHeap(), 0, | 
|---|
| 580 | (LPCSTR)cs->szTitle ); | 
|---|
| 581 | *plparam = (LPARAM)cs; | 
|---|
| 582 | } | 
|---|
| 583 | return 1; | 
|---|
| 584 |  | 
|---|
| 585 | /* Listbox */ | 
|---|
| 586 | case LB_ADDSTRING: | 
|---|
| 587 | #ifdef __WIN32OS2__ | 
|---|
| 588 | case LB_FINDSTRING: | 
|---|
| 589 | case LB_FINDSTRINGEXACT: | 
|---|
| 590 | case LB_SELECTSTRING: | 
|---|
| 591 | #endif | 
|---|
| 592 | case LB_INSERTSTRING: | 
|---|
| 593 | if ( WINPROC_TestLBForStr( hwnd )) | 
|---|
| 594 | *plparam = (LPARAM)HEAP_strdupAtoW( GetProcessHeap(), 0, (LPCSTR)*plparam ); | 
|---|
| 595 | return (*plparam ? 1 : -1); | 
|---|
| 596 |  | 
|---|
| 597 | case LB_GETTEXT:                /* fixme: fixed sized buffer */ | 
|---|
| 598 | { if ( WINPROC_TestLBForStr( hwnd )) | 
|---|
| 599 | { LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0, 256 * sizeof(WCHAR) + sizeof(LPARAM) ); | 
|---|
| 600 | if (!ptr) return -1; | 
|---|
| 601 | *ptr++ = *plparam;  /* Store previous lParam */ | 
|---|
| 602 | *plparam = (LPARAM)ptr; | 
|---|
| 603 | } | 
|---|
| 604 | } | 
|---|
| 605 | return 1; | 
|---|
| 606 |  | 
|---|
| 607 | /* Combobox */ | 
|---|
| 608 | case CB_ADDSTRING: | 
|---|
| 609 | #ifdef __WIN32OS2__ | 
|---|
| 610 | case CB_FINDSTRING: | 
|---|
| 611 | case CB_FINDSTRINGEXACT: | 
|---|
| 612 | case CB_SELECTSTRING: | 
|---|
| 613 | #endif | 
|---|
| 614 | case CB_INSERTSTRING: | 
|---|
| 615 | if ( WINPROC_TestCBForStr( hwnd )) | 
|---|
| 616 | *plparam = (LPARAM)HEAP_strdupAtoW( GetProcessHeap(), 0, (LPCSTR)*plparam ); | 
|---|
| 617 | return (*plparam ? 1 : -1); | 
|---|
| 618 |  | 
|---|
| 619 | case CB_GETLBTEXT:    /* fixme: fixed sized buffer */ | 
|---|
| 620 | { if ( WINPROC_TestCBForStr( hwnd )) | 
|---|
| 621 | { LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0, 256 * sizeof(WCHAR) + sizeof(LPARAM) ); | 
|---|
| 622 | if (!ptr) return -1; | 
|---|
| 623 | *ptr++ = *plparam;  /* Store previous lParam */ | 
|---|
| 624 | *plparam = (LPARAM)ptr; | 
|---|
| 625 | } | 
|---|
| 626 | } | 
|---|
| 627 | return 1; | 
|---|
| 628 |  | 
|---|
| 629 | /* Multiline edit */ | 
|---|
| 630 | case EM_GETLINE: | 
|---|
| 631 | { WORD len = (WORD)*plparam; | 
|---|
| 632 | LPARAM *ptr = (LPARAM *) HEAP_xalloc( GetProcessHeap(), 0, sizeof(LPARAM) + sizeof (WORD) + len*sizeof(WCHAR) ); | 
|---|
| 633 | if (!ptr) return -1; | 
|---|
| 634 | *ptr++ = *plparam;  /* Store previous lParam */ | 
|---|
| 635 | *((WORD *) ptr) = len;   /* Store the length */ | 
|---|
| 636 | *plparam = (LPARAM)ptr; | 
|---|
| 637 | } | 
|---|
| 638 | return 1; | 
|---|
| 639 |  | 
|---|
| 640 | case WM_ASKCBFORMATNAME: | 
|---|
| 641 | case WM_DEVMODECHANGE: | 
|---|
| 642 | case WM_PAINTCLIPBOARD: | 
|---|
| 643 | case WM_SIZECLIPBOARD: | 
|---|
| 644 | case EM_SETPASSWORDCHAR: | 
|---|
| 645 | // FIXME_(msg)("message %s (0x%x) needs translation, please report\n", SPY_GetMsgName(msg), msg ); | 
|---|
| 646 | return -1; | 
|---|
| 647 | default:  /* No translation needed */ | 
|---|
| 648 | return 0; | 
|---|
| 649 | } | 
|---|
| 650 | } | 
|---|
| 651 |  | 
|---|
| 652 |  | 
|---|
| 653 | /********************************************************************** | 
|---|
| 654 | *           WINPROC_UnmapMsg32ATo32W | 
|---|
| 655 | * | 
|---|
| 656 | * Unmap a message that was mapped from Ansi to Unicode. | 
|---|
| 657 | */ | 
|---|
| 658 | void WINPROC_UnmapMsg32ATo32W( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) | 
|---|
| 659 | { | 
|---|
| 660 | switch(msg) | 
|---|
| 661 | { | 
|---|
| 662 | case WM_GETTEXT: | 
|---|
| 663 | { | 
|---|
| 664 | LPARAM *ptr = (LPARAM *)lParam - 1; | 
|---|
| 665 | lstrcpynWtoA( (LPSTR)*ptr, (LPWSTR)lParam, wParam ); | 
|---|
| 666 | HeapFree( GetProcessHeap(), 0, ptr ); | 
|---|
| 667 | } | 
|---|
| 668 | break; | 
|---|
| 669 |  | 
|---|
| 670 | case WM_NCCREATE: | 
|---|
| 671 | case WM_CREATE: | 
|---|
| 672 | { | 
|---|
| 673 | CREATESTRUCTW *cs = (CREATESTRUCTW *)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 | MDICREATESTRUCTW *cs = (MDICREATESTRUCTW *)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 | case WM_SETTEXT: | 
|---|
| 694 | case WM_WININICHANGE: | 
|---|
| 695 | case CB_DIR: | 
|---|
| 696 | case LB_DIR: | 
|---|
| 697 | case LB_ADDFILE: | 
|---|
| 698 | #ifndef __WIN32OS2__ | 
|---|
| 699 | case CB_FINDSTRING: | 
|---|
| 700 | case CB_FINDSTRINGEXACT: | 
|---|
| 701 | case CB_SELECTSTRING: | 
|---|
| 702 | case LB_FINDSTRING: | 
|---|
| 703 | case LB_SELECTSTRING: | 
|---|
| 704 | #endif | 
|---|
| 705 | case EM_REPLACESEL: | 
|---|
| 706 | HeapFree( GetProcessHeap(), 0, (void *)lParam ); | 
|---|
| 707 | break; | 
|---|
| 708 |  | 
|---|
| 709 | /* Listbox */ | 
|---|
| 710 | case LB_ADDSTRING: | 
|---|
| 711 | #ifdef __WIN32OS2__ | 
|---|
| 712 | case LB_FINDSTRING: | 
|---|
| 713 | case LB_FINDSTRINGEXACT: | 
|---|
| 714 | case LB_SELECTSTRING: | 
|---|
| 715 | #endif | 
|---|
| 716 | case LB_INSERTSTRING: | 
|---|
| 717 | if ( WINPROC_TestLBForStr( hwnd )) | 
|---|
| 718 | HeapFree( GetProcessHeap(), 0, (void *)lParam ); | 
|---|
| 719 | break; | 
|---|
| 720 |  | 
|---|
| 721 | case LB_GETTEXT: | 
|---|
| 722 | { if ( WINPROC_TestLBForStr( hwnd )) | 
|---|
| 723 | { LPARAM *ptr = (LPARAM *)lParam - 1; | 
|---|
| 724 | lstrcpyWtoA( (LPSTR)*ptr, (LPWSTR)(lParam) ); | 
|---|
| 725 | HeapFree( GetProcessHeap(), 0, ptr ); | 
|---|
| 726 | } | 
|---|
| 727 | } | 
|---|
| 728 | break; | 
|---|
| 729 |  | 
|---|
| 730 | /* Combobox */ | 
|---|
| 731 | case CB_ADDSTRING: | 
|---|
| 732 | #ifdef __WIN32OS2__ | 
|---|
| 733 | case CB_FINDSTRING: | 
|---|
| 734 | case CB_FINDSTRINGEXACT: | 
|---|
| 735 | case CB_SELECTSTRING: | 
|---|
| 736 | #endif | 
|---|
| 737 | case CB_INSERTSTRING: | 
|---|
| 738 | if ( WINPROC_TestCBForStr( hwnd )) | 
|---|
| 739 | HeapFree( GetProcessHeap(), 0, (void *)lParam ); | 
|---|
| 740 | break; | 
|---|
| 741 |  | 
|---|
| 742 | case CB_GETLBTEXT: | 
|---|
| 743 | { if ( WINPROC_TestCBForStr( hwnd )) | 
|---|
| 744 | { LPARAM *ptr = (LPARAM *)lParam - 1; | 
|---|
| 745 | lstrcpyWtoA( (LPSTR)*ptr, (LPWSTR)(lParam) ); | 
|---|
| 746 | HeapFree( GetProcessHeap(), 0, ptr ); | 
|---|
| 747 | } | 
|---|
| 748 | } | 
|---|
| 749 | break; | 
|---|
| 750 |  | 
|---|
| 751 | /* Multiline edit */ | 
|---|
| 752 | case EM_GETLINE: | 
|---|
| 753 | { LPARAM * ptr = (LPARAM *)lParam - 1;  /* get the old lParam */ | 
|---|
| 754 | WORD len = *(WORD *) lParam; | 
|---|
| 755 | lstrcpynWtoA( (LPSTR)*ptr , (LPWSTR)lParam, len ); | 
|---|
| 756 | HeapFree( GetProcessHeap(), 0, ptr ); | 
|---|
| 757 | } | 
|---|
| 758 | break; | 
|---|
| 759 | } | 
|---|
| 760 | } | 
|---|
| 761 |  | 
|---|
| 762 |  | 
|---|
| 763 | /********************************************************************** | 
|---|
| 764 | *           WINPROC_MapMsg32WTo32A | 
|---|
| 765 | * | 
|---|
| 766 | * Map a message from Unicode to Ansi. | 
|---|
| 767 | * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed. | 
|---|
| 768 | */ | 
|---|
| 769 | INT WINPROC_MapMsg32WTo32A( HWND hwnd, UINT msg, WPARAM wParam, LPARAM *plparam) | 
|---|
| 770 | {   switch(msg) | 
|---|
| 771 | { | 
|---|
| 772 | case WM_GETTEXT: | 
|---|
| 773 | { | 
|---|
| 774 | LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0, | 
|---|
| 775 | wParam + sizeof(LPARAM) ); | 
|---|
| 776 | if (!ptr) return -1; | 
|---|
| 777 | *ptr++ = *plparam;  /* Store previous lParam */ | 
|---|
| 778 | *plparam = (LPARAM)ptr; | 
|---|
| 779 | } | 
|---|
| 780 | return 1; | 
|---|
| 781 |  | 
|---|
| 782 | case WM_SETTEXT: | 
|---|
| 783 | case WM_WININICHANGE: | 
|---|
| 784 | case CB_DIR: | 
|---|
| 785 | case LB_DIR: | 
|---|
| 786 | case LB_ADDFILE: | 
|---|
| 787 | #ifndef __WIN32OS2__ | 
|---|
| 788 | case CB_FINDSTRING: | 
|---|
| 789 | case CB_FINDSTRINGEXACT: | 
|---|
| 790 | case CB_SELECTSTRING: | 
|---|
| 791 | case LB_FINDSTRING: | 
|---|
| 792 | case LB_SELECTSTRING: | 
|---|
| 793 | #endif | 
|---|
| 794 | case EM_REPLACESEL: | 
|---|
| 795 | *plparam = (LPARAM)HEAP_strdupWtoA( GetProcessHeap(), 0, (LPCWSTR)*plparam ); | 
|---|
| 796 | return (*plparam ? 1 : -1); | 
|---|
| 797 |  | 
|---|
| 798 | case WM_NCCREATE: | 
|---|
| 799 | case WM_CREATE: | 
|---|
| 800 | { | 
|---|
| 801 | CREATESTRUCTA *cs = (CREATESTRUCTA *)HeapAlloc( GetProcessHeap(), 0, | 
|---|
| 802 | sizeof(*cs) ); | 
|---|
| 803 | if (!cs) return -1; | 
|---|
| 804 | *cs = *(CREATESTRUCTA *)*plparam; | 
|---|
| 805 | if (HIWORD(cs->lpszName)) | 
|---|
| 806 | cs->lpszName  = HEAP_strdupWtoA( GetProcessHeap(), 0, | 
|---|
| 807 | (LPCWSTR)cs->lpszName ); | 
|---|
| 808 | if (HIWORD(cs->lpszClass)) | 
|---|
| 809 | cs->lpszClass = HEAP_strdupWtoA( GetProcessHeap(), 0, | 
|---|
| 810 | (LPCWSTR)cs->lpszClass); | 
|---|
| 811 | *plparam = (LPARAM)cs; | 
|---|
| 812 | } | 
|---|
| 813 | return 1; | 
|---|
| 814 | case WM_MDICREATE: | 
|---|
| 815 | { | 
|---|
| 816 | MDICREATESTRUCTA *cs = | 
|---|
| 817 | (MDICREATESTRUCTA *)HeapAlloc( GetProcessHeap(), 0, sizeof(*cs) ); | 
|---|
| 818 |  | 
|---|
| 819 | if (!cs) return -1; | 
|---|
| 820 | *cs = *(MDICREATESTRUCTA *)*plparam; | 
|---|
| 821 | if (HIWORD(cs->szTitle)) | 
|---|
| 822 | cs->szTitle = HEAP_strdupWtoA( GetProcessHeap(), 0, | 
|---|
| 823 | (LPCWSTR)cs->szTitle ); | 
|---|
| 824 | if (HIWORD(cs->szClass)) | 
|---|
| 825 | cs->szClass = HEAP_strdupWtoA( GetProcessHeap(), 0, | 
|---|
| 826 | (LPCWSTR)cs->szClass ); | 
|---|
| 827 | *plparam = (LPARAM)cs; | 
|---|
| 828 | } | 
|---|
| 829 | return 1; | 
|---|
| 830 |  | 
|---|
| 831 | /* Listbox */ | 
|---|
| 832 | case LB_ADDSTRING: | 
|---|
| 833 | #ifdef __WIN32OS2__ | 
|---|
| 834 | case LB_FINDSTRING: | 
|---|
| 835 | case LB_FINDSTRINGEXACT: | 
|---|
| 836 | case LB_SELECTSTRING: | 
|---|
| 837 | #endif | 
|---|
| 838 | case LB_INSERTSTRING: | 
|---|
| 839 | if ( WINPROC_TestLBForStr( hwnd )) | 
|---|
| 840 | *plparam = (LPARAM)HEAP_strdupWtoA( GetProcessHeap(), 0, (LPCWSTR)*plparam ); | 
|---|
| 841 | return (*plparam ? 1 : -1); | 
|---|
| 842 |  | 
|---|
| 843 | case LB_GETTEXT:                    /* fixme: fixed sized buffer */ | 
|---|
| 844 | { if ( WINPROC_TestLBForStr( hwnd )) | 
|---|
| 845 | { LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0, 256 + sizeof(LPARAM) ); | 
|---|
| 846 | if (!ptr) return -1; | 
|---|
| 847 | *ptr++ = *plparam;  /* Store previous lParam */ | 
|---|
| 848 | *plparam = (LPARAM)ptr; | 
|---|
| 849 | } | 
|---|
| 850 | } | 
|---|
| 851 | return 1; | 
|---|
| 852 |  | 
|---|
| 853 | /* Combobox */ | 
|---|
| 854 | case CB_ADDSTRING: | 
|---|
| 855 | #ifdef __WIN32OS2__ | 
|---|
| 856 | case CB_FINDSTRING: | 
|---|
| 857 | case CB_FINDSTRINGEXACT: | 
|---|
| 858 | case CB_SELECTSTRING: | 
|---|
| 859 | #endif | 
|---|
| 860 | case CB_INSERTSTRING: | 
|---|
| 861 | if ( WINPROC_TestCBForStr( hwnd )) | 
|---|
| 862 | *plparam = (LPARAM)HEAP_strdupWtoA( GetProcessHeap(), 0, (LPCWSTR)*plparam ); | 
|---|
| 863 | return (*plparam ? 1 : -1); | 
|---|
| 864 |  | 
|---|
| 865 | case CB_GETLBTEXT:          /* fixme: fixed sized buffer */ | 
|---|
| 866 | { if ( WINPROC_TestCBForStr( hwnd )) | 
|---|
| 867 | { LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0, 256 + sizeof(LPARAM) ); | 
|---|
| 868 | if (!ptr) return -1; | 
|---|
| 869 | *ptr++ = *plparam;  /* Store previous lParam */ | 
|---|
| 870 | *plparam = (LPARAM)ptr; | 
|---|
| 871 | } | 
|---|
| 872 | } | 
|---|
| 873 | return 1; | 
|---|
| 874 |  | 
|---|
| 875 | /* Multiline edit */ | 
|---|
| 876 | case EM_GETLINE: | 
|---|
| 877 | { WORD len = (WORD)*plparam; | 
|---|
| 878 | LPARAM *ptr = (LPARAM *) HEAP_xalloc( GetProcessHeap(), 0, sizeof(LPARAM) + sizeof (WORD) + len*sizeof(CHAR) ); | 
|---|
| 879 | if (!ptr) return -1; | 
|---|
| 880 | *ptr++ = *plparam;  /* Store previous lParam */ | 
|---|
| 881 | *((WORD *) ptr) = len;   /* Store the length */ | 
|---|
| 882 | *plparam = (LPARAM)ptr; | 
|---|
| 883 | } | 
|---|
| 884 | return 1; | 
|---|
| 885 |  | 
|---|
| 886 | case WM_ASKCBFORMATNAME: | 
|---|
| 887 | case WM_DEVMODECHANGE: | 
|---|
| 888 | case WM_PAINTCLIPBOARD: | 
|---|
| 889 | case WM_SIZECLIPBOARD: | 
|---|
| 890 | case EM_SETPASSWORDCHAR: | 
|---|
| 891 | // FIXME_(msg)("message %s (%04x) needs translation, please report\n",SPY_GetMsgName(msg),msg ); | 
|---|
| 892 | return -1; | 
|---|
| 893 | default:  /* No translation needed */ | 
|---|
| 894 | return 0; | 
|---|
| 895 | } | 
|---|
| 896 | } | 
|---|
| 897 |  | 
|---|
| 898 |  | 
|---|
| 899 | /********************************************************************** | 
|---|
| 900 | *           WINPROC_UnmapMsg32WTo32A | 
|---|
| 901 | * | 
|---|
| 902 | * Unmap a message that was mapped from Unicode to Ansi. | 
|---|
| 903 | */ | 
|---|
| 904 | void WINPROC_UnmapMsg32WTo32A( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) | 
|---|
| 905 | { | 
|---|
| 906 | switch(msg) | 
|---|
| 907 | { | 
|---|
| 908 | case WM_GETTEXT: | 
|---|
| 909 | { | 
|---|
| 910 | LPARAM *ptr = (LPARAM *)lParam - 1; | 
|---|
| 911 | lstrcpynAtoW( (LPWSTR)*ptr, (LPSTR)lParam, wParam ); | 
|---|
| 912 | HeapFree( GetProcessHeap(), 0, ptr ); | 
|---|
| 913 | } | 
|---|
| 914 | break; | 
|---|
| 915 |  | 
|---|
| 916 | case WM_SETTEXT: | 
|---|
| 917 | case WM_WININICHANGE: | 
|---|
| 918 | case CB_DIR: | 
|---|
| 919 | case LB_DIR: | 
|---|
| 920 | case LB_ADDFILE: | 
|---|
| 921 | #ifndef __WIN32OS2__ | 
|---|
| 922 | case CB_FINDSTRING: | 
|---|
| 923 | case CB_FINDSTRINGEXACT: | 
|---|
| 924 | case CB_SELECTSTRING: | 
|---|
| 925 | case LB_FINDSTRING: | 
|---|
| 926 | case LB_SELECTSTRING: | 
|---|
| 927 | #endif | 
|---|
| 928 | case EM_REPLACESEL: | 
|---|
| 929 | HeapFree( GetProcessHeap(), 0, (void *)lParam ); | 
|---|
| 930 | break; | 
|---|
| 931 |  | 
|---|
| 932 | case WM_NCCREATE: | 
|---|
| 933 | case WM_CREATE: | 
|---|
| 934 | { | 
|---|
| 935 | CREATESTRUCTA *cs = (CREATESTRUCTA *)lParam; | 
|---|
| 936 | if (HIWORD(cs->lpszName)) | 
|---|
| 937 | HeapFree( GetProcessHeap(), 0, (LPVOID)cs->lpszName ); | 
|---|
| 938 | if (HIWORD(cs->lpszClass)) | 
|---|
| 939 | HeapFree( GetProcessHeap(), 0, (LPVOID)cs->lpszClass ); | 
|---|
| 940 | HeapFree( GetProcessHeap(), 0, cs ); | 
|---|
| 941 | } | 
|---|
| 942 | break; | 
|---|
| 943 |  | 
|---|
| 944 | case WM_MDICREATE: | 
|---|
| 945 | { | 
|---|
| 946 | MDICREATESTRUCTA *cs = (MDICREATESTRUCTA *)lParam; | 
|---|
| 947 | if (HIWORD(cs->szTitle)) | 
|---|
| 948 | HeapFree( GetProcessHeap(), 0, (LPVOID)cs->szTitle ); | 
|---|
| 949 | if (HIWORD(cs->szClass)) | 
|---|
| 950 | HeapFree( GetProcessHeap(), 0, (LPVOID)cs->szClass ); | 
|---|
| 951 | HeapFree( GetProcessHeap(), 0, cs ); | 
|---|
| 952 | } | 
|---|
| 953 | break; | 
|---|
| 954 |  | 
|---|
| 955 | /* Listbox */ | 
|---|
| 956 | case LB_ADDSTRING: | 
|---|
| 957 | #ifdef __WIN32OS2__ | 
|---|
| 958 | case LB_FINDSTRING: | 
|---|
| 959 | case LB_FINDSTRINGEXACT: | 
|---|
| 960 | case LB_SELECTSTRING: | 
|---|
| 961 | #endif | 
|---|
| 962 | case LB_INSERTSTRING: | 
|---|
| 963 | if ( WINPROC_TestLBForStr( hwnd )) | 
|---|
| 964 | HeapFree( GetProcessHeap(), 0, (void *)lParam ); | 
|---|
| 965 | break; | 
|---|
| 966 |  | 
|---|
| 967 | case LB_GETTEXT: | 
|---|
| 968 | { if ( WINPROC_TestLBForStr( hwnd )) | 
|---|
| 969 | { LPARAM *ptr = (LPARAM *)lParam - 1; | 
|---|
| 970 | lstrcpyAtoW( (LPWSTR)*ptr, (LPSTR)(lParam) ); | 
|---|
| 971 | HeapFree(GetProcessHeap(), 0, ptr ); | 
|---|
| 972 | } | 
|---|
| 973 | } | 
|---|
| 974 | break; | 
|---|
| 975 |  | 
|---|
| 976 | /* Combobox */ | 
|---|
| 977 | case CB_ADDSTRING: | 
|---|
| 978 | #ifdef __WIN32OS2__ | 
|---|
| 979 | case CB_FINDSTRING: | 
|---|
| 980 | case CB_FINDSTRINGEXACT: | 
|---|
| 981 | case CB_SELECTSTRING: | 
|---|
| 982 | #endif | 
|---|
| 983 | case CB_INSERTSTRING: | 
|---|
| 984 | if ( WINPROC_TestCBForStr( hwnd )) | 
|---|
| 985 | HeapFree( GetProcessHeap(), 0, (void *)lParam ); | 
|---|
| 986 | break; | 
|---|
| 987 |  | 
|---|
| 988 | case CB_GETLBTEXT: | 
|---|
| 989 | { if ( WINPROC_TestCBForStr( hwnd )) | 
|---|
| 990 | { LPARAM *ptr = (LPARAM *)lParam - 1; | 
|---|
| 991 | lstrcpyAtoW( (LPWSTR)*ptr, (LPSTR)(lParam) ); | 
|---|
| 992 | HeapFree( GetProcessHeap(), 0, ptr ); | 
|---|
| 993 | } | 
|---|
| 994 | } | 
|---|
| 995 | break; | 
|---|
| 996 |  | 
|---|
| 997 | /* Multiline edit */ | 
|---|
| 998 | case EM_GETLINE: | 
|---|
| 999 | { LPARAM * ptr = (LPARAM *)lParam - 1;  /* get the old lparam */ | 
|---|
| 1000 | WORD len = *(WORD *)ptr; | 
|---|
| 1001 | lstrcpynAtoW( (LPWSTR) *ptr, (LPSTR)lParam, len ); | 
|---|
| 1002 | HeapFree( GetProcessHeap(), 0, ptr ); | 
|---|
| 1003 | } | 
|---|
| 1004 | break; | 
|---|
| 1005 | } | 
|---|
| 1006 | } | 
|---|
| 1007 |  | 
|---|
| 1008 | /********************************************************************** | 
|---|
| 1009 | *           WINPROC_CallProc32ATo32W | 
|---|
| 1010 | * | 
|---|
| 1011 | * Call a window procedure, translating args from Ansi to Unicode. | 
|---|
| 1012 | */ | 
|---|
| 1013 | LRESULT WINPROC_CallProc32ATo32W( WNDPROC func, HWND hwnd, | 
|---|
| 1014 | UINT msg, WPARAM wParam, | 
|---|
| 1015 | LPARAM lParam ) | 
|---|
| 1016 | { | 
|---|
| 1017 | LRESULT result; | 
|---|
| 1018 |  | 
|---|
| 1019 | if (WINPROC_MapMsg32ATo32W( hwnd, msg, wParam, &lParam ) == -1) return 0; | 
|---|
| 1020 | result = func( hwnd, msg, wParam, lParam ); | 
|---|
| 1021 | WINPROC_UnmapMsg32ATo32W( hwnd, msg, wParam, lParam ); | 
|---|
| 1022 | return result; | 
|---|
| 1023 | } | 
|---|
| 1024 |  | 
|---|
| 1025 | /********************************************************************** | 
|---|
| 1026 | *           WINPROC_CallProc32WTo32A | 
|---|
| 1027 | * | 
|---|
| 1028 | * Call a window procedure, translating args from Unicode to Ansi. | 
|---|
| 1029 | */ | 
|---|
| 1030 | LRESULT WINPROC_CallProc32WTo32A( WNDPROC func, HWND hwnd, | 
|---|
| 1031 | UINT msg, WPARAM wParam, | 
|---|
| 1032 | LPARAM lParam ) | 
|---|
| 1033 | { | 
|---|
| 1034 | LRESULT result; | 
|---|
| 1035 |  | 
|---|
| 1036 | if (WINPROC_MapMsg32WTo32A( hwnd, msg, wParam, &lParam ) == -1) return 0; | 
|---|
| 1037 |  | 
|---|
| 1038 | result = func( hwnd, msg, wParam, lParam ); | 
|---|
| 1039 | WINPROC_UnmapMsg32WTo32A( hwnd, msg, wParam, lParam ); | 
|---|
| 1040 | return result; | 
|---|
| 1041 | } | 
|---|
| 1042 | //****************************************************************************** | 
|---|
| 1043 | //TODO: QS_HOTKEY (oslibmsg.cpp) & low word bits | 
|---|
| 1044 | //high word = messages currently in queue | 
|---|
| 1045 | //low word  = messages that have been added to the queue and are still in the | 
|---|
| 1046 | //            queue since the last call to GetQueueStatus | 
|---|
| 1047 | //****************************************************************************** | 
|---|
| 1048 | DWORD WIN32API GetQueueStatus( UINT flags) | 
|---|
| 1049 | { | 
|---|
| 1050 | DWORD queueStatus; | 
|---|
| 1051 |  | 
|---|
| 1052 | queueStatus = OSLibWinQueryQueueStatus(); | 
|---|
| 1053 | queueStatus = MAKELONG(queueStatus, queueStatus); | 
|---|
| 1054 |  | 
|---|
| 1055 | dprintf(("USER32: GetQueueStatus %x returned %x", flags, queueStatus & MAKELONG(flags, flags))); | 
|---|
| 1056 |  | 
|---|
| 1057 | return queueStatus & MAKELONG(flags, flags); | 
|---|
| 1058 | } | 
|---|
| 1059 | /***************************************************************************** | 
|---|
| 1060 | * Name      : BOOL WIN32API GetInputState | 
|---|
| 1061 | * Purpose   : The GetInputState function determines whether there are | 
|---|
| 1062 | *             mouse-button or keyboard messages in the calling thread's message queue. | 
|---|
| 1063 | * Parameters: | 
|---|
| 1064 | * Variables : | 
|---|
| 1065 | * Result    : If the queue contains one or more new mouse-button or keyboard | 
|---|
| 1066 | *               messages, the return value is TRUE. | 
|---|
| 1067 | *             If the function fails, the return value is FALSE. | 
|---|
| 1068 | * Remark    : | 
|---|
| 1069 | * Status    : UNTESTED STUB | 
|---|
| 1070 | * | 
|---|
| 1071 | * Author    : Patrick Haller [Thu, 1998/02/26 11:55] | 
|---|
| 1072 | *****************************************************************************/ | 
|---|
| 1073 | BOOL WIN32API GetInputState(VOID) | 
|---|
| 1074 | { | 
|---|
| 1075 | DWORD queueStatus; | 
|---|
| 1076 | BOOL  rc; | 
|---|
| 1077 |  | 
|---|
| 1078 | queueStatus = OSLibWinQueryQueueStatus(); | 
|---|
| 1079 |  | 
|---|
| 1080 | rc = (queueStatus & (QS_KEY | QS_MOUSEBUTTON)) ? TRUE : FALSE; | 
|---|
| 1081 | dprintf(("USER32:GetInputState() returned %d", rc)); | 
|---|
| 1082 | return rc; | 
|---|
| 1083 | } | 
|---|
| 1084 | //****************************************************************************** | 
|---|
| 1085 | /* Synchronization Functions */ | 
|---|
| 1086 | //****************************************************************************** | 
|---|
| 1087 | DWORD WIN32API MsgWaitForMultipleObjects(DWORD nCount, LPHANDLE pHandles, BOOL fWaitAll, | 
|---|
| 1088 | DWORD dwMilliseconds, DWORD dwWakeMask) | 
|---|
| 1089 | { | 
|---|
| 1090 | DWORD curtime, endtime, ret; | 
|---|
| 1091 | MSG msg; | 
|---|
| 1092 |  | 
|---|
| 1093 | dprintf(("MsgWaitForMultipleObjects %x %x %d %d %x", nCount, pHandles, fWaitAll, dwMilliseconds, dwWakeMask)); | 
|---|
| 1094 | // @@@PH this is a temporary bugfix for WINFILE.EXE | 
|---|
| 1095 | if (nCount == 0) | 
|---|
| 1096 | { | 
|---|
| 1097 | if(dwMilliseconds == 0) { | 
|---|
| 1098 | if(GetQueueStatus(dwWakeMask) == 0) { | 
|---|
| 1099 | return WAIT_TIMEOUT; | 
|---|
| 1100 | } | 
|---|
| 1101 | return WAIT_OBJECT_0; | 
|---|
| 1102 | } | 
|---|
| 1103 | //SvL: Check time, wait for any message, check msg type and determine if | 
|---|
| 1104 | //     we have to return | 
|---|
| 1105 | //TODO: Timeout isn't handled correctly (can return too late) | 
|---|
| 1106 | curtime = GetCurrentTime(); | 
|---|
| 1107 | endtime = curtime + dwMilliseconds; | 
|---|
| 1108 | while(curtime < endtime || dwMilliseconds == INFINITE) { | 
|---|
| 1109 | if(OSLibWinWaitMessage() == FALSE) { | 
|---|
| 1110 | dprintf(("OSLibWinWaitMessage returned FALSE!")); | 
|---|
| 1111 | return WAIT_ABANDONED; | 
|---|
| 1112 | } | 
|---|
| 1113 | if(GetQueueStatus(dwWakeMask) != 0) { | 
|---|
| 1114 | return WAIT_OBJECT_0; | 
|---|
| 1115 | } | 
|---|
| 1116 | //TODO: Ignoring all messages could be dangerous. But processing them, | 
|---|
| 1117 | //while the app doesn't expect any, isn't safe either. | 
|---|
| 1118 | if(PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)) | 
|---|
| 1119 | { | 
|---|
| 1120 | if (msg.message == WM_QUIT) { | 
|---|
| 1121 | dprintf(("ERROR: MsgWaitForMultipleObjects call abandoned because WM_QUIT msg was received!!")); | 
|---|
| 1122 | return WAIT_ABANDONED; | 
|---|
| 1123 | } | 
|---|
| 1124 |  | 
|---|
| 1125 | /* otherwise dispatch it */ | 
|---|
| 1126 | DispatchMessageA(&msg); | 
|---|
| 1127 | } | 
|---|
| 1128 | curtime = GetCurrentTime(); | 
|---|
| 1129 | } | 
|---|
| 1130 | return WAIT_TIMEOUT; | 
|---|
| 1131 | } | 
|---|
| 1132 | //SvL: Call handlemanager function as we need to translate handles | 
|---|
| 1133 | //TODO: doesn't work at all if waiting for message | 
|---|
| 1134 | ret = HMMsgWaitForMultipleObjects(nCount,pHandles,fWaitAll,dwMilliseconds,dwWakeMask); | 
|---|
| 1135 | return ret; | 
|---|
| 1136 | } | 
|---|