Module: wine Branch: refs/heads/master Commit: b34521c43d364410c52b01c40986662936937c1e URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=b34521c43d364410c52b01c4...
Author: Alexandre Julliard julliard@winehq.org Date: Thu May 18 12:17:44 2006 +0200
user: Added fast W->A mapping for LB_GETTEXT and CB_GETLBTEXT.
---
dlls/user/winproc.c | 88 +++++++++++++++++++++++---------------------------- 1 files changed, 40 insertions(+), 48 deletions(-)
diff --git a/dlls/user/winproc.c b/dlls/user/winproc.c index fe9905b..d4b0db5 100644 --- a/dlls/user/winproc.c +++ b/dlls/user/winproc.c @@ -992,28 +992,6 @@ static INT WINPROC_MapMsg32WTo32A( HWND { switch(msg) { -/* Listbox */ - case LB_GETTEXT: /* FIXME: fixed sized buffer */ - { if ( WINPROC_TestLBForStr( hwnd )) - { LPARAM *ptr = HeapAlloc( GetProcessHeap(), 0, 512 + sizeof(LPARAM) ); - if (!ptr) return -1; - *ptr++ = *plparam; /* Store previous lParam */ - *plparam = (LPARAM)ptr; - } - } - return 1; - -/* Combobox */ - case CB_GETLBTEXT: /* FIXME: fixed sized buffer */ - { if ( WINPROC_TestCBForStr( hwnd )) - { LPARAM *ptr = HeapAlloc( GetProcessHeap(), 0, 512 + sizeof(LPARAM) ); - if (!ptr) return -1; - *ptr++ = *plparam; /* Store previous lParam */ - *plparam = (LPARAM)ptr; - } - } - return 1; - /* Multiline edit */ case EM_GETLINE: { WORD len = (WORD)*plparam; @@ -1071,32 +1049,6 @@ static LRESULT WINPROC_UnmapMsg32WTo32A( { switch(msg) { -/* Listbox */ - case LB_GETTEXT: - if ( WINPROC_TestLBForStr( hwnd )) - { - LPARAM *ptr = (LPARAM *)lParam - 1; - if (result >= 0) - result = MultiByteToWideChar( CP_ACP, 0, (LPSTR)lParam, -1, (LPWSTR)*ptr, 0x7fffffff ) - 1; - HeapFree( GetProcessHeap(), 0, ptr ); - } - break; - -/* Combobox */ - case CB_GETLBTEXT: - if ( result < 0) /* CB_ERR and CB_ERRSPACE */ - { - LPARAM *ptr = (LPARAM *)lParam - 1; - HeapFree( GetProcessHeap(), 0, ptr ); - } - else if ( WINPROC_TestCBForStr( hwnd )) - { - LPARAM *ptr = (LPARAM *)lParam - 1; - result = MultiByteToWideChar( CP_ACP, 0, (LPSTR)lParam, -1, (LPWSTR)*ptr, 0x7fffffff ) - 1; - HeapFree( GetProcessHeap(), 0, ptr ); - } - break; - /* Multiline edit */ case EM_GETLINE: { @@ -3019,6 +2971,26 @@ static LRESULT WINPROC_CallProc32WTo32A( ret = WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam ); break;
+ case LB_GETTEXT: + if (lParam && WINPROC_TestLBForStr( hwnd )) + { + char buffer[512]; /* FIXME: fixed sized buffer */ + LRESULT result; + + ret = WINPROC_CallWndProc( func, hwnd, msg, wParam, (LPARAM)buffer ); + result = dialog ? GetWindowLongPtrW( hwnd, DWLP_MSGRESULT ) : ret; + if (result >= 0) + { + DWORD len; + RtlMultiByteToUnicodeN( (LPWSTR)lParam, ~0u, &len, buffer, strlen(buffer) + 1 ); + result = len / sizeof(WCHAR) - 1; + if (dialog) SetWindowLongPtrW( hwnd, DWLP_MSGRESULT, result ); + else ret = result; + } + } + else ret = WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam ); + break; + /* Combobox */ case CB_ADDSTRING: case CB_INSERTSTRING: @@ -3029,6 +3001,26 @@ static LRESULT WINPROC_CallProc32WTo32A( ret = WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam ); break;
+ case CB_GETLBTEXT: + if (lParam && WINPROC_TestCBForStr( hwnd )) + { + char buffer[512]; /* FIXME: fixed sized buffer */ + LRESULT result; + + ret = WINPROC_CallWndProc( func, hwnd, msg, wParam, (LPARAM)buffer ); + result = dialog ? GetWindowLongPtrW( hwnd, DWLP_MSGRESULT ) : ret; + if (result >= 0) + { + DWORD len; + RtlMultiByteToUnicodeN( (LPWSTR)lParam, ~0u, &len, buffer, strlen(buffer) + 1 ); + result = len / sizeof(WCHAR) - 1; + if (dialog) SetWindowLongPtrW( hwnd, DWLP_MSGRESULT, result ); + else ret = result; + } + } + else ret = WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam ); + break; + default: if ((unmap = WINPROC_MapMsg32WTo32A( hwnd, msg, &wParam, &lParam )) == -1) { ERR_(msg)("Message translation failed. (msg=%s,wp=%08x,lp=%08lx)\n",