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