Ignore:
Timestamp:
Dec 26, 1999, 6:30:20 PM (26 years ago)
Author:
cbratschi
Message:

non-client fixes, DefWndProc enhancements, several other bugs fixed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/windowmsg.cpp

    r2200 r2204  
    1 /* $Id: windowmsg.cpp,v 1.11 1999-12-24 18:39:13 sandervl Exp $ */
     1/* $Id: windowmsg.cpp,v 1.12 1999-12-26 17:30:20 cbratschi Exp $ */
    22/*
    33 * Win32 window message APIs for OS/2
     
    1111 * TODO: GetQueueStatus: QS_HOTKEY (oslibmsg.cpp) & low word bits
    1212 * TODO: MsgWaitForMultipleObjects: timeout isn't handled correctly (can return too late)
    13  * TODO: GetMessageExtraInfo
    1413 *
    1514 * Project Odin Software License can be found in LICENSE.TXT
     
    2221#include <heapstring.h>
    2322#include <handlemanager.h>
     23#include "oslibutil.h"
    2424#include "oslibwin.h"
    2525#include "oslibmsg.h"
     
    9595}
    9696//******************************************************************************
    97 //TODO: 
     97//TODO:
    9898//******************************************************************************
    9999LONG WIN32API GetMessageExtraInfo()
    100100{
    101     dprintf(("USER32: GetMessageExtraInfo NOT SUPPORTED"));
    102     return 0;
     101    dprintf(("USER32: GetMessageExtraInfo"));
     102    return GetThreadMessageExtraInfo();
    103103}
    104104//******************************************************************************
     
    124124    if (hwnd == HWND_BROADCAST|| hwnd == HWND_TOPMOST)
    125125    {
    126         Win32BaseWindow::BroadcastMessageA(BROADCAST_SEND, msg, wParam, lParam);
    127         return TRUE;
     126        Win32BaseWindow::BroadcastMessageA(BROADCAST_SEND, msg, wParam, lParam);
     127        return TRUE;
    128128    }
    129129
     
    143143    if (hwnd == HWND_BROADCAST|| hwnd == HWND_TOPMOST)
    144144    {
    145         Win32BaseWindow::BroadcastMessageW(BROADCAST_SEND, msg, wParam, lParam);
    146         return TRUE;
     145        Win32BaseWindow::BroadcastMessageW(BROADCAST_SEND, msg, wParam, lParam);
     146        return TRUE;
    147147    }
    148148
     
    162162    if (hwnd == HWND_BROADCAST) //Not HWND_TOPMOST???
    163163    {
    164         Win32BaseWindow::BroadcastMessageA(BROADCAST_POST, msg, wParam, lParam);
    165         return TRUE;
     164        Win32BaseWindow::BroadcastMessageA(BROADCAST_POST, msg, wParam, lParam);
     165        return TRUE;
    166166    }
    167167
     
    185185    if (hwnd == HWND_BROADCAST) //Not HWND_TOPMOST???
    186186    {
    187         Win32BaseWindow::BroadcastMessageW(BROADCAST_POST, msg, wParam, lParam);
    188         return TRUE;
     187        Win32BaseWindow::BroadcastMessageW(BROADCAST_POST, msg, wParam, lParam);
     188        return TRUE;
    189189    }
    190190
     
    264264}
    265265//******************************************************************************
    266 //No need to support this
     266//No need to support this (obsolete, not implemented by Win32)
    267267//******************************************************************************
    268268BOOL WIN32API SetMessageQueue(int cMessagesMax)
     
    320320{
    321321#ifdef DEBUG
    322   WriteLog("USER32:  SetMessageExtraInfo, not implemented\n");
     322  WriteLog("USER32:  SetMessageExtraInfo\n");
    323323#endif
    324   return(0);
     324  return SetThreadMessageExtraInfo(lParam);
    325325}
    326326/*****************************************************************************
     
    447447//******************************************************************************
    448448/**********************************************************************
    449  *           WINPROC_TestCBForStr
     449 *           WINPROC_TestCBForStr
    450450 *
    451451 * Return TRUE if the lparam is a string
     
    454454{
    455455    BOOL retvalue;
    456     DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); 
     456    DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
    457457    retvalue = ( !(LOWORD(dwStyle) & (CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE)) ||
    458               (LOWORD(dwStyle) & CBS_HASSTRINGS) );
     458              (LOWORD(dwStyle) & CBS_HASSTRINGS) );
    459459    return retvalue;
    460460}
    461461/**********************************************************************
    462  *           WINPROC_TestLBForStr
     462 *           WINPROC_TestLBForStr
    463463 *
    464464 * Return TRUE if the lparam is a string
     
    467467{
    468468    BOOL retvalue;
    469     DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); 
     469    DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
    470470    retvalue = ( !(LOWORD(dwStyle) & (LBS_OWNERDRAWFIXED | LBS_OWNERDRAWVARIABLE)) ||
    471             (LOWORD(dwStyle) & LBS_HASSTRINGS) );
     471            (LOWORD(dwStyle) & LBS_HASSTRINGS) );
    472472    return retvalue;
    473473}
    474474
    475475/**********************************************************************
    476  *           WINPROC_MapMsg32ATo32W
     476 *           WINPROC_MapMsg32ATo32W
    477477 *
    478478 * Map a message from Ansi to Unicode.
     
    484484 * FIXME:
    485485 *  WM_GETTEXT/WM_SETTEXT and static control with SS_ICON style:
    486  *  the first four bytes are the handle of the icon 
     486 *  the first four bytes are the handle of the icon
    487487 *  when the WM_SETTEXT message has been used to set the icon
    488488 */
     
    550550    case LB_ADDSTRING:
    551551    case LB_INSERTSTRING:
    552         if ( WINPROC_TestLBForStr( hwnd ))
     552        if ( WINPROC_TestLBForStr( hwnd ))
    553553          *plparam = (LPARAM)HEAP_strdupAtoW( GetProcessHeap(), 0, (LPCSTR)*plparam );
    554554        return (*plparam ? 1 : -1);
    555555
    556     case LB_GETTEXT:                /* fixme: fixed sized buffer */
     556    case LB_GETTEXT:                /* fixme: fixed sized buffer */
    557557        { if ( WINPROC_TestLBForStr( hwnd ))
    558           { LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0, 256 * sizeof(WCHAR) + sizeof(LPARAM) );
     558          { LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0, 256 * sizeof(WCHAR) + sizeof(LPARAM) );
    559559            if (!ptr) return -1;
    560560            *ptr++ = *plparam;  /* Store previous lParam */
    561561            *plparam = (LPARAM)ptr;
    562           }
     562          }
    563563        }
    564564        return 1;
     
    567567    case CB_ADDSTRING:
    568568    case CB_INSERTSTRING:
    569         if ( WINPROC_TestCBForStr( hwnd ))
     569        if ( WINPROC_TestCBForStr( hwnd ))
    570570          *plparam = (LPARAM)HEAP_strdupAtoW( GetProcessHeap(), 0, (LPCSTR)*plparam );
    571571        return (*plparam ? 1 : -1);
     
    577577            *ptr++ = *plparam;  /* Store previous lParam */
    578578            *plparam = (LPARAM)ptr;
    579           }
     579          }
    580580        }
    581581        return 1;
     
    584584    case EM_GETLINE:
    585585        { WORD len = (WORD)*plparam;
    586           LPARAM *ptr = (LPARAM *) HEAP_xalloc( GetProcessHeap(), 0, sizeof(LPARAM) + sizeof (WORD) + len*sizeof(WCHAR) );
     586          LPARAM *ptr = (LPARAM *) HEAP_xalloc( GetProcessHeap(), 0, sizeof(LPARAM) + sizeof (WORD) + len*sizeof(WCHAR) );
    587587          if (!ptr) return -1;
    588588          *ptr++ = *plparam;  /* Store previous lParam */
    589           *((WORD *) ptr) = len;   /* Store the length */
     589          *((WORD *) ptr) = len;   /* Store the length */
    590590          *plparam = (LPARAM)ptr;
    591         }
     591        }
    592592        return 1;
    593593
     
    606606
    607607/**********************************************************************
    608  *           WINPROC_UnmapMsg32ATo32W
     608 *           WINPROC_UnmapMsg32ATo32W
    609609 *
    610610 * Unmap a message that was mapped from Ansi to Unicode.
     
    662662    case LB_ADDSTRING:
    663663    case LB_INSERTSTRING:
    664         if ( WINPROC_TestLBForStr( hwnd ))
     664        if ( WINPROC_TestLBForStr( hwnd ))
    665665          HeapFree( GetProcessHeap(), 0, (void *)lParam );
    666666        break;
     
    669669        { if ( WINPROC_TestLBForStr( hwnd ))
    670670          { LPARAM *ptr = (LPARAM *)lParam - 1;
    671             lstrcpyWtoA( (LPSTR)*ptr, (LPWSTR)(lParam) );
     671            lstrcpyWtoA( (LPSTR)*ptr, (LPWSTR)(lParam) );
    672672            HeapFree( GetProcessHeap(), 0, ptr );
    673           }
     673          }
    674674        }
    675675        break;
     
    678678    case CB_ADDSTRING:
    679679    case CB_INSERTSTRING:
    680         if ( WINPROC_TestCBForStr( hwnd ))
     680        if ( WINPROC_TestCBForStr( hwnd ))
    681681          HeapFree( GetProcessHeap(), 0, (void *)lParam );
    682682        break;
     
    684684    case CB_GETLBTEXT:
    685685        { if ( WINPROC_TestCBForStr( hwnd ))
    686           { LPARAM *ptr = (LPARAM *)lParam - 1;
     686          { LPARAM *ptr = (LPARAM *)lParam - 1;
    687687            lstrcpyWtoA( (LPSTR)*ptr, (LPWSTR)(lParam) );
    688688            HeapFree( GetProcessHeap(), 0, ptr );
    689           }
     689          }
    690690        }
    691691        break;
     
    694694    case EM_GETLINE:
    695695        { LPARAM * ptr = (LPARAM *)lParam - 1;  /* get the old lParam */
    696           WORD len = *(WORD *) lParam;
     696          WORD len = *(WORD *) lParam;
    697697          lstrcpynWtoA( (LPSTR)*ptr , (LPWSTR)lParam, len );
    698698          HeapFree( GetProcessHeap(), 0, ptr );
     
    704704
    705705/**********************************************************************
    706  *           WINPROC_MapMsg32WTo32A
     706 *           WINPROC_MapMsg32WTo32A
    707707 *
    708708 * Map a message from Unicode to Ansi.
     
    772772    case LB_ADDSTRING:
    773773    case LB_INSERTSTRING:
    774         if ( WINPROC_TestLBForStr( hwnd ))
     774        if ( WINPROC_TestLBForStr( hwnd ))
    775775          *plparam = (LPARAM)HEAP_strdupWtoA( GetProcessHeap(), 0, (LPCWSTR)*plparam );
    776776        return (*plparam ? 1 : -1);
    777777
    778     case LB_GETTEXT:                    /* fixme: fixed sized buffer */
     778    case LB_GETTEXT:                    /* fixme: fixed sized buffer */
    779779        { if ( WINPROC_TestLBForStr( hwnd ))
    780           { LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0, 256 + sizeof(LPARAM) );
     780          { LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0, 256 + sizeof(LPARAM) );
    781781            if (!ptr) return -1;
    782782            *ptr++ = *plparam;  /* Store previous lParam */
    783783            *plparam = (LPARAM)ptr;
    784           }
     784          }
    785785        }
    786786        return 1;
     
    789789    case CB_ADDSTRING:
    790790    case CB_INSERTSTRING:
    791         if ( WINPROC_TestCBForStr( hwnd ))
     791        if ( WINPROC_TestCBForStr( hwnd ))
    792792          *plparam = (LPARAM)HEAP_strdupWtoA( GetProcessHeap(), 0, (LPCWSTR)*plparam );
    793793        return (*plparam ? 1 : -1);
    794794
    795     case CB_GETLBTEXT:          /* fixme: fixed sized buffer */
     795    case CB_GETLBTEXT:          /* fixme: fixed sized buffer */
    796796        { if ( WINPROC_TestCBForStr( hwnd ))
    797           { LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0, 256 + sizeof(LPARAM) );
     797          { LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0, 256 + sizeof(LPARAM) );
    798798            if (!ptr) return -1;
    799799            *ptr++ = *plparam;  /* Store previous lParam */
    800800            *plparam = (LPARAM)ptr;
    801           }
     801          }
    802802        }
    803803        return 1;
     
    806806    case EM_GETLINE:
    807807        { WORD len = (WORD)*plparam;
    808           LPARAM *ptr = (LPARAM *) HEAP_xalloc( GetProcessHeap(), 0, sizeof(LPARAM) + sizeof (WORD) + len*sizeof(CHAR) );
     808          LPARAM *ptr = (LPARAM *) HEAP_xalloc( GetProcessHeap(), 0, sizeof(LPARAM) + sizeof (WORD) + len*sizeof(CHAR) );
    809809          if (!ptr) return -1;
    810810          *ptr++ = *plparam;  /* Store previous lParam */
    811           *((WORD *) ptr) = len;   /* Store the length */
     811          *((WORD *) ptr) = len;   /* Store the length */
    812812          *plparam = (LPARAM)ptr;
    813         }
     813        }
    814814        return 1;
    815815
     
    828828
    829829/**********************************************************************
    830  *           WINPROC_UnmapMsg32WTo32A
     830 *           WINPROC_UnmapMsg32WTo32A
    831831 *
    832832 * Unmap a message that was mapped from Unicode to Ansi.
     
    884884    case LB_ADDSTRING:
    885885    case LB_INSERTSTRING:
    886         if ( WINPROC_TestLBForStr( hwnd ))
     886        if ( WINPROC_TestLBForStr( hwnd ))
    887887          HeapFree( GetProcessHeap(), 0, (void *)lParam );
    888888        break;
     
    893893            lstrcpyAtoW( (LPWSTR)*ptr, (LPSTR)(lParam) );
    894894            HeapFree(GetProcessHeap(), 0, ptr );
    895           }
     895          }
    896896        }
    897897        break;
     
    900900    case CB_ADDSTRING:
    901901    case CB_INSERTSTRING:
    902         if ( WINPROC_TestCBForStr( hwnd ))
     902        if ( WINPROC_TestCBForStr( hwnd ))
    903903          HeapFree( GetProcessHeap(), 0, (void *)lParam );
    904904        break;
     
    909909            lstrcpyAtoW( (LPWSTR)*ptr, (LPSTR)(lParam) );
    910910            HeapFree( GetProcessHeap(), 0, ptr );
    911           }
     911          }
    912912        }
    913913        break;
     
    916916    case EM_GETLINE:
    917917        { LPARAM * ptr = (LPARAM *)lParam - 1;  /* get the old lparam */
    918           WORD len = *(WORD *)ptr;
     918          WORD len = *(WORD *)ptr;
    919919          lstrcpynAtoW( (LPWSTR) *ptr, (LPSTR)lParam, len );
    920920          HeapFree( GetProcessHeap(), 0, ptr );
     
    925925
    926926/**********************************************************************
    927  *           WINPROC_CallProc32ATo32W
     927 *           WINPROC_CallProc32ATo32W
    928928 *
    929929 * Call a window procedure, translating args from Ansi to Unicode.
     
    942942
    943943/**********************************************************************
    944  *           WINPROC_CallProc32WTo32A
     944 *           WINPROC_CallProc32WTo32A
    945945 *
    946946 * Call a window procedure, translating args from Unicode to Ansi.
     
    970970    dprintf(("USER32:  GetQueueStatus"));
    971971    queueStatus = OSLibWinQueryQueueStatus();
    972  
     972
    973973    queueStatus = MAKELONG(queueStatus, queueStatus);
    974974    return queueStatus & MAKELONG(flags, flags);
     
    10111011  if (nCount == 0)
    10121012  {
    1013         if(dwMilliseconds == 0) {
    1014                 if(GetQueueStatus(dwWakeMask) == 0) {
    1015                         return WAIT_TIMEOUT;
    1016                 }
    1017                 return WAIT_OBJECT_0;
    1018         }
     1013        if(dwMilliseconds == 0) {
     1014                if(GetQueueStatus(dwWakeMask) == 0) {
     1015                        return WAIT_TIMEOUT;
     1016                }
     1017                return WAIT_OBJECT_0;
     1018        }
    10191019        //SvL: Check time, wait for any message, check msg type and determine if
    10201020        //     we have to return
    1021         //TODO: Timeout isn't handled correctly (can return too late)
    1022         curtime = GetCurrentTime();
     1021        //TODO: Timeout isn't handled correctly (can return too late)
     1022        curtime = GetCurrentTime();
    10231023        endtime = curtime + dwMilliseconds;
    1024         while(curtime < endtime || dwMilliseconds == INFINITE) {
    1025                 if(OSLibWinWaitMessage() == FALSE) {
    1026                         dprintf(("OSLibWinWaitMessage returned FALSE!"));
    1027                         return -1;
    1028                 }
    1029                 if(GetQueueStatus(dwWakeMask) != 0) {
    1030                         return WAIT_OBJECT_0;
    1031                 }
    1032                 curtime = GetCurrentTime();
    1033         }
     1024        while(curtime < endtime || dwMilliseconds == INFINITE) {
     1025                if(OSLibWinWaitMessage() == FALSE) {
     1026                        dprintf(("OSLibWinWaitMessage returned FALSE!"));
     1027                        return -1;
     1028                }
     1029                if(GetQueueStatus(dwWakeMask) != 0) {
     1030                        return WAIT_OBJECT_0;
     1031                }
     1032                curtime = GetCurrentTime();
     1033        }
    10341034        return WAIT_TIMEOUT;
    10351035  }
Note: See TracChangeset for help on using the changeset viewer.