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