Ignore:
Timestamp:
Jul 31, 2003, 5:58:58 PM (22 years ago)
Author:
sandervl
Message:

KOMH: DBCS updates/fixes

File:
1 edited

Legend:

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

    r10185 r10190  
    1 /* $Id: windowmsg.cpp,v 1.43 2003-07-28 11:27:50 sandervl Exp $ */
     1/* $Id: windowmsg.cpp,v 1.44 2003-07-31 15:56:47 sandervl Exp $ */
    22/*
    33 * Win32 window message APIs for OS/2
     
    8686                return 0; /* invalid winproc */
    8787
    88             return CallWindowProcA( (WNDPROC)msg->lParam, msg->hwnd,
     88            return CallWindowProcW( (WNDPROC)msg->lParam, msg->hwnd,
    8989                                   msg->message, msg->wParam, GetTickCount() );
    9090        }
     
    319319    {
    320320    case WM_GETTEXT:
     321    case WM_ASKCBFORMATNAME:
    321322        {
    322323            LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0,
     
    330331    case WM_SETTEXT:
    331332    case WM_WININICHANGE:
     333    case WM_DEVMODECHANGE:
    332334    case CB_DIR:
    333335    case LB_DIR:
     
    431433        return 1;
    432434
    433     /* kso 2003-07-03: to make password field work, I took this from latest wine code. (winproc.c) */
     435    case WM_CHARTOITEM:
     436    case WM_MENUCHAR:
     437    case WM_CHAR:
     438    case WM_DEADCHAR:
     439    case WM_SYSCHAR:
     440    case WM_SYSDEADCHAR:
    434441    case EM_SETPASSWORDCHAR:
    435442        {
    436             BYTE    ch = LOWORD(*pwparam);
    437             WCHAR   wch = 0;
    438             MultiByteToWideChar(CP_ACP, 0, (LPCSTR)&ch, 1, &wch, 1);
     443            char ch = LOWORD(*pwparam);
     444            WCHAR wch;
     445            MultiByteToWideChar(CP_ACP, 0, &ch, 1, &wch, 1);
    439446            *pwparam = MAKEWPARAM( wch, HIWORD(*pwparam) );
    440447        }
    441448        return 0;
    442449
    443     case WM_ASKCBFORMATNAME:
    444     case WM_DEVMODECHANGE:
    445450    case WM_PAINTCLIPBOARD:
    446451    case WM_SIZECLIPBOARD:
     
    463468    {
    464469    case WM_GETTEXT:
     470    case WM_ASKCBFORMATNAME:
    465471        {
    466472            LPARAM *ptr = (LPARAM *)lParam - 1;
     
    495501    case WM_SETTEXT:
    496502    case WM_WININICHANGE:
     503    case WM_DEVMODECHANGE:
    497504    case CB_DIR:
    498505    case LB_DIR:
     
    569576 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
    570577 */
    571 INT WINPROC_MapMsg32WTo32A( HWND hwnd, UINT msg, WPARAM wParam, LPARAM *plparam)
     578INT WINPROC_MapMsg32WTo32A( HWND hwnd, UINT msg, WPARAM *pwparam, LPARAM *plparam)
    572579{   switch(msg)
    573580    {
    574581    case WM_GETTEXT:
    575         {
     582    case WM_ASKCBFORMATNAME:
     583        {
     584#ifdef __WIN32OS2__
     585            *pwparam = *pwparam * sizeof( WCHAR );  //DBCS
     586#endif
    576587            LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0,
    577                                                wParam + sizeof(LPARAM) );
     588                                               *pwparam + sizeof(LPARAM) );
    578589            if (!ptr) return -1;
    579590            *ptr++ = *plparam;  /* Store previous lParam */
     
    584595    case WM_SETTEXT:
    585596    case WM_WININICHANGE:
     597    case WM_DEVMODECHANGE:
    586598    case CB_DIR:
    587599    case LB_DIR:
     
    681693          if (!ptr) return -1;
    682694          *ptr++ = *plparam;  /* Store previous lParam */
     695#ifdef __WIN32OS2__
     696          *((WORD *) ptr) = len * sizeof(WCHAR);   /* Store the length */
     697#else
    683698          *((WORD *) ptr) = len;   /* Store the length */
     699#endif
    684700          *plparam = (LPARAM)ptr;
    685701        }
    686702        return 1;
    687703
    688     case WM_ASKCBFORMATNAME:
    689     case WM_DEVMODECHANGE:
     704    case WM_CHARTOITEM:
     705    case WM_MENUCHAR:
     706    case WM_CHAR:
     707    case WM_DEADCHAR:
     708    case WM_SYSCHAR:
     709    case WM_SYSDEADCHAR:
     710    case EM_SETPASSWORDCHAR:
     711        {
     712            WCHAR wch = LOWORD(*pwparam);
     713            char ch;
     714            WideCharToMultiByte( CP_ACP, 0, &wch, 1, &ch, 1, NULL, NULL );
     715            *pwparam = MAKEWPARAM( ch, HIWORD(*pwparam) );
     716        }
     717        return 0;
     718
    690719    case WM_PAINTCLIPBOARD:
    691720    case WM_SIZECLIPBOARD:
    692     case EM_SETPASSWORDCHAR:
    693721        // FIXME_(msg)("message %s (%04x) needs translation, please report\n",SPY_GetMsgName(msg),msg );
    694722        return -1;
     
    709737    {
    710738    case WM_GETTEXT:
     739    case WM_ASKCBFORMATNAME:
    711740        {
    712741            LPARAM *ptr = (LPARAM *)lParam - 1;
     742
     743#ifdef __WIN32OS2__
     744            wParam = wParam / sizeof( WCHAR );
     745#endif
    713746            lstrcpynAtoW( (LPWSTR)*ptr, (LPSTR)lParam, wParam );
    714747            HeapFree( GetProcessHeap(), 0, ptr );
     
    718751    case WM_SETTEXT:
    719752    case WM_WININICHANGE:
     753    case WM_DEVMODECHANGE:
    720754    case CB_DIR:
    721755    case LB_DIR:
     
    800834    case EM_GETLINE:
    801835        { LPARAM * ptr = (LPARAM *)lParam - 1;  /* get the old lparam */
     836#ifdef __WIN32OS2__
     837          WORD len = *(WORD *)ptr/sizeof(WCHAR);
     838#else
    802839          WORD len = *(WORD *)ptr;
     840#endif
    803841          lstrcpynAtoW( (LPWSTR) *ptr, (LPSTR)lParam, len );
    804842          HeapFree( GetProcessHeap(), 0, ptr );
     
    819857    LRESULT result;
    820858
     859#ifdef __WIN32OS2__
     860    if( IsDBCSEnv() && msg == WM_CHAR )
     861    {
     862        static BYTE dbcsLead = 0;
     863        WCHAR charA = wParam;
     864        int size = dbcsLead ? 2 : 1;
     865
     866        if( dbcsLead )
     867               charA = ( charA << 8 ) | dbcsLead;
     868        else if( IsDBCSLeadByte( wParam ))
     869        {
     870            dbcsLead = wParam;
     871            return 0;
     872        }
     873        MultiByteToWideChar( CP_ACP, 0, ( LPSTR )&charA, size, ( LPWSTR )&wParam, 1 );
     874
     875        dbcsLead = 0;
     876    }
     877    else
     878#endif
    821879    if (WINPROC_MapMsg32ATo32W( hwnd, msg, &wParam, &lParam ) == -1) return 0;
     880
    822881    result = func( hwnd, msg, wParam, lParam );
    823882    WINPROC_UnmapMsg32ATo32W( hwnd, msg, wParam, lParam );
     883
     884#ifdef __WIN32OS2__
     885    if(IsDBCSEnv())
     886    {
     887      switch( msg )
     888      {
     889        case WM_GETTEXTLENGTH :
     890        {
     891            LPWSTR ustr = ( LPWSTR )HeapAlloc( GetProcessHeap(), 0, ( result + 1 ) * sizeof( WCHAR ));
     892            result = func( hwnd, WM_GETTEXT, ( WPARAM )( result + 1 ), ( LPARAM )ustr );
     893            result = lstrlenWtoA( ustr, result );
     894            HeapFree( GetProcessHeap(), 0, ustr );
     895            break;
     896        }
     897
     898        case LB_GETTEXTLEN :
     899        {
     900            LPWSTR ustr = ( LPWSTR )HeapAlloc( GetProcessHeap(), 0, ( result + 1 ) * sizeof( WCHAR ));
     901            result = func( hwnd, LB_GETTEXT, wParam, ( LPARAM )ustr );
     902            if( result != LB_ERR )
     903                result = lstrlenWtoA( ustr, result );
     904
     905            HeapFree( GetProcessHeap(), 0, ustr );
     906            break;
     907        }
     908
     909
     910        case CB_GETLBTEXTLEN :
     911        {
     912            LPWSTR ustr = ( LPWSTR )HeapAlloc( GetProcessHeap(), 0, ( result + 1 ) * sizeof( WCHAR ));
     913            result = func( hwnd, CB_GETLBTEXT, wParam, ( LPARAM )ustr );
     914            if( result != CB_ERR )
     915                result = lstrlenWtoA( ustr, result );
     916
     917            HeapFree( GetProcessHeap(), 0, ustr );
     918            break;
     919        }
     920      }
     921    }
     922#endif
    824923    return result;
    825924}
     
    836935    LRESULT result;
    837936
    838     if (WINPROC_MapMsg32WTo32A( hwnd, msg, wParam, &lParam ) == -1) return 0;
     937#ifdef __WIN32OS2__
     938    if( IsDBCSEnv() && msg == WM_CHAR )
     939    {
     940        char charA[ 2 ];
     941
     942        if( WideCharToMultiByte( CP_ACP, 0, ( LPWSTR )&wParam, 1, ( LPSTR )charA, 2, 0, 0 ) > 1 )
     943        {
     944            func( hwnd, msg, ( WPARAM )charA[ 0 ], lParam );
     945            wParam = charA[ 1 ];
     946        }
     947        else
     948            wParam = charA[ 0 ];
     949    }
     950    else
     951#endif
     952    if (WINPROC_MapMsg32WTo32A( hwnd, msg, &wParam, &lParam ) == -1) return 0;
    839953
    840954    result = func( hwnd, msg, wParam, lParam );
    841955    WINPROC_UnmapMsg32WTo32A( hwnd, msg, wParam, lParam );
     956
     957#ifdef __WIN32OS2__
     958    if( IsDBCSEnv() )
     959    {
     960      switch( msg )
     961      {
     962        case WM_GETTEXTLENGTH :
     963        {
     964            LPSTR astr = ( LPSTR )HeapAlloc( GetProcessHeap(), 0, result + 1 );
     965            result = func( hwnd, WM_GETTEXT, ( WPARAM )( result + 1 ), ( LPARAM )astr );
     966            result = lstrlenAtoW( astr, result );
     967            HeapFree( GetProcessHeap(), 0, astr );
     968            break;
     969        }
     970
     971        case LB_GETTEXTLEN :
     972        {
     973            LPSTR astr = ( LPSTR )HeapAlloc( GetProcessHeap(), 0, result + 1 );
     974            result = func( hwnd, LB_GETTEXT, wParam, ( LPARAM )astr );
     975            if( result != LB_ERR )
     976                result = lstrlenAtoW( astr, result );
     977
     978            HeapFree( GetProcessHeap(), 0, astr );
     979            break;
     980        }
     981
     982
     983        case CB_GETLBTEXTLEN :
     984        {
     985            LPSTR astr = ( LPSTR )HeapAlloc( GetProcessHeap(), 0, result + 1 );
     986            result = func( hwnd, CB_GETLBTEXT, wParam, ( LPARAM )astr );
     987            if( result != CB_ERR )
     988                result = lstrlenAtoW( astr, result );
     989
     990            HeapFree( GetProcessHeap(), 0, astr );
     991            break;
     992        }
     993      }
     994    }
     995#endif
    842996    return result;
    843997}
Note: See TracChangeset for help on using the changeset viewer.