Hi,
I've a rather strange problem. Some windows (iirc all of them are dialog windows) have crippled window titles. Only the first character is dispayed.
I've tried to tackle this bug down, but it was a major PITA and i was somehow unsuccessfull. What i've found out so far is:
1. GetWindowTextA( ... WM_GETTEXT ... ) is called to resolve the window title. 2. SendMessageA( ... WM_GETTEXT ... ) is called 3. SendMessageTimeoutA( ... WM_GETTEXT ... ) is called 4. call_window_proc( ... WM_GETTEXT ... unicode==FALSE ...) is called 5. CallWindowProcA( ... WM_GETTEXT ... ) is called 6. if (!proc) return WINPROC_CallWndProc( ... WM_GETTEXT ... ) is called
<< here i was unable to resolve the codepath futher down >>
But i was able to find the codepath a bit later again:
?. DefWindowProcW( ... WM_GETTEXT ... ) is called
Somehow wine (or the application) managed to route the GetWindowTextA( ... WM_GETTEXT ... ) ansi call to the DefWindowProcW( ... WM_GETTEXT ... ) unicode handler. Maybe someone has a clue how to tackle this bug down?
I've attached a patch which will work around this issue. It's an ugly hack so i don't propose it for cvs inclusion.
Regards, Florian Schirmer
--- windows/win.c-old Wed Jan 8 22:09:25 2003 +++ windows/win.c Fri Mar 7 14:23:47 2003 @@ -2264,15 +2264,33 @@ INT WINAPI GetWindowTextA( HWND hwnd, LP { WCHAR *buffer;
- if (WIN_IsCurrentProcess( hwnd )) - return (INT)SendMessageA( hwnd, WM_GETTEXT, nMaxCount, (LPARAM)lpString ); - - /* when window belongs to other process, don't send a message */ if (nMaxCount <= 0) return 0; if (!(buffer = HeapAlloc( GetProcessHeap(), 0, nMaxCount * sizeof(WCHAR) ))) return 0; - get_server_window_text( hwnd, buffer, nMaxCount ); - if (!WideCharToMultiByte( CP_ACP, 0, buffer, -1, lpString, nMaxCount, NULL, NULL )) - lpString[nMaxCount-1] = 0; + + if (WIN_IsCurrentProcess( hwnd )) { + + SendMessageA( hwnd, WM_GETTEXT, nMaxCount, (LPARAM)buffer ); + + if (strlen((char *)buffer) == 1) { + + if (!WideCharToMultiByte( CP_ACP, 0, buffer, -1, lpString, nMaxCount, NULL, NULL )) + lpString[nMaxCount-1] = 0; + + } else { + + strncpy(lpString, (char *)buffer, nMaxCount); + + } + + } else { + + /* when window belongs to other process, don't send a message */ + get_server_window_text( hwnd, buffer, nMaxCount ); + if (!WideCharToMultiByte( CP_ACP, 0, buffer, -1, lpString, nMaxCount, NULL, NULL )) + lpString[nMaxCount-1] = 0; + + } + HeapFree( GetProcessHeap(), 0, buffer ); return strlen(lpString); }