comctl32: Truncate the info tip text when using ANSI version messages.

This commit is contained in:
Akihiro Sagawa 2012-04-13 22:45:22 +09:00 committed by Alexandre Julliard
parent 28f26c9783
commit 8cedea0d60
2 changed files with 10 additions and 6 deletions

View File

@ -668,7 +668,7 @@ static void test_longtextA(void)
toolinfoA.lpszText = bufA; toolinfoA.lpszText = bufA;
SendMessageA(hwnd, TTM_ENUMTOOLSA, 0, (LPARAM)&toolinfoA); SendMessageA(hwnd, TTM_ENUMTOOLSA, 0, (LPARAM)&toolinfoA);
textlen = lstrlenA(toolinfoA.lpszText); textlen = lstrlenA(toolinfoA.lpszText);
todo_wine ok(textlen == 80, "lpszText has %d chars\n", textlen); ok(textlen == 80, "lpszText has %d chars\n", textlen);
ok(toolinfoA.uId == 0x1234ABCD, ok(toolinfoA.uId == 0x1234ABCD,
"uId should be retrieved, got %p\n", (void*)toolinfoA.uId); "uId should be retrieved, got %p\n", (void*)toolinfoA.uId);
@ -678,7 +678,7 @@ static void test_longtextA(void)
toolinfoA.lpszText = bufA; toolinfoA.lpszText = bufA;
SendMessageA(hwnd, TTM_GETTOOLINFOA, 0, (LPARAM)&toolinfoA); SendMessageA(hwnd, TTM_GETTOOLINFOA, 0, (LPARAM)&toolinfoA);
textlen = lstrlenA(toolinfoA.lpszText); textlen = lstrlenA(toolinfoA.lpszText);
todo_wine ok(textlen == 80, "lpszText has %d chars\n", textlen); ok(textlen == 80, "lpszText has %d chars\n", textlen);
memset(bufA, 0, sizeof(bufA)); memset(bufA, 0, sizeof(bufA));
toolinfoA.hwnd = NULL; toolinfoA.hwnd = NULL;
@ -686,7 +686,7 @@ static void test_longtextA(void)
toolinfoA.lpszText = bufA; toolinfoA.lpszText = bufA;
SendMessageA(hwnd, TTM_GETTEXTA, 0, (LPARAM)&toolinfoA); SendMessageA(hwnd, TTM_GETTEXTA, 0, (LPARAM)&toolinfoA);
textlen = lstrlenA(toolinfoA.lpszText); textlen = lstrlenA(toolinfoA.lpszText);
todo_wine ok(textlen == 80, "lpszText has %d chars\n", textlen); ok(textlen == 80, "lpszText has %d chars\n", textlen);
} }
DestroyWindow(hwnd); DestroyWindow(hwnd);

View File

@ -171,6 +171,8 @@ typedef struct
#define ICON_HEIGHT 16 #define ICON_HEIGHT 16
#define ICON_WIDTH 16 #define ICON_WIDTH 16
#define MAX_TEXT_SIZE_A 80 /* maximum retriving text size by ANSI message */
static LRESULT CALLBACK static LRESULT CALLBACK
TOOLTIPS_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uId, DWORD_PTR dwRef); TOOLTIPS_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uId, DWORD_PTR dwRef);
@ -954,8 +956,9 @@ TOOLTIPS_CopyInfoT (const TTTOOL_INFO *toolPtr, TTTOOLINFOW *ti, BOOL isW)
else if (isW) else if (isW)
strcpyW (ti->lpszText, toolPtr->lpszText); strcpyW (ti->lpszText, toolPtr->lpszText);
else else
/* ANSI version, the buffer is maximum 80 bytes without null. */
WideCharToMultiByte(CP_ACP, 0, toolPtr->lpszText, -1, WideCharToMultiByte(CP_ACP, 0, toolPtr->lpszText, -1,
(LPSTR)ti->lpszText, INFOTIPSIZE, NULL, NULL); (LPSTR)ti->lpszText, MAX_TEXT_SIZE_A, NULL, NULL);
} }
} }
@ -1341,12 +1344,13 @@ TOOLTIPS_GetTextT (const TOOLTIPS_INFO *infoPtr, TTTOOLINFOW *ti, BOOL isW)
/* NB this API is broken, there is no way for the app to determine /* NB this API is broken, there is no way for the app to determine
what size buffer it requires nor a way to specify how long the what size buffer it requires nor a way to specify how long the
one it supplies is. We'll assume it's up to INFOTIPSIZE */ one it supplies is. According to the test result, it's up to
80 bytes by the ANSI version. */
buffer[0] = '\0'; buffer[0] = '\0';
TOOLTIPS_GetTipText(infoPtr, nTool, buffer); TOOLTIPS_GetTipText(infoPtr, nTool, buffer);
WideCharToMultiByte(CP_ACP, 0, buffer, -1, (LPSTR)ti->lpszText, WideCharToMultiByte(CP_ACP, 0, buffer, -1, (LPSTR)ti->lpszText,
INFOTIPSIZE, NULL, NULL); MAX_TEXT_SIZE_A, NULL, NULL);
} }
return 0; return 0;