From b48f394e4f3ee73eb2f974d19770d411d13f3e62 Mon Sep 17 00:00:00 2001 From: Akihiro Sagawa Date: Thu, 12 Apr 2012 00:42:55 +0900 Subject: [PATCH] comctl32: Add support for retrieving lpszText in TOOLINFO structure. --- dlls/comctl32/tests/tooltips.c | 16 ++++++++++++++++ dlls/comctl32/tooltips.c | 27 +++++++++++++++++++-------- 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/dlls/comctl32/tests/tooltips.c b/dlls/comctl32/tests/tooltips.c index 596598f1ade..31504d1b3cb 100644 --- a/dlls/comctl32/tests/tooltips.c +++ b/dlls/comctl32/tests/tooltips.c @@ -322,6 +322,11 @@ static void test_gettext(void) toolinfoA.lpszText = bufA; SendMessageA(hwnd, TTM_GETTEXTA, 0, (LPARAM)&toolinfoA); ok(strcmp(toolinfoA.lpszText, "") == 0, "lpszText should be an empty string\n"); + + toolinfoA.lpszText = bufA; + SendMessageA(hwnd, TTM_GETTOOLINFOA, 0, (LPARAM)&toolinfoA); + ok(toolinfoA.lpszText == NULL, + "expected NULL, got %p", toolinfoA.lpszText); } else { @@ -355,6 +360,12 @@ static void test_gettext(void) SendMessageA(hwnd, TTM_GETTEXTA, 0, (LPARAM)&toolinfoA); ok(strcmp(toolinfoA.lpszText, testtipA) == 0, "lpszText should be an empty string\n"); + memset(bufA, 0x1f, sizeof(bufA)); + toolinfoA.lpszText = bufA; + SendMessageA(hwnd, TTM_GETTOOLINFOA, 0, (LPARAM)&toolinfoA); + ok(strcmp(toolinfoA.lpszText, testtipA) == 0, + "expected %s, got %p\n", testtipA, toolinfoA.lpszText); + length = SendMessage(hwnd, WM_GETTEXTLENGTH, 0, 0); ok(length == 0, "Expected 0, got %d\n", length); } @@ -378,6 +389,11 @@ static void test_gettext(void) SendMessageA(hwnd, TTM_GETTEXTA, 0, (LPARAM)&toolinfoA); ok(strcmp(toolinfoA.lpszText, testcallbackA) == 0, "lpszText should be an (%s) string\n", testcallbackA); + + toolinfoA.lpszText = bufA; + SendMessageA(hwnd, TTM_GETTOOLINFOA, 0, (LPARAM)&toolinfoA); + ok(toolinfoA.lpszText == LPSTR_TEXTCALLBACKA, + "expected LPSTR_TEXTCALLBACKA, got %p\n", toolinfoA.lpszText); } DestroyWindow(hwnd); diff --git a/dlls/comctl32/tooltips.c b/dlls/comctl32/tooltips.c index 162867d7150..1d758b4e498 100644 --- a/dlls/comctl32/tooltips.c +++ b/dlls/comctl32/tooltips.c @@ -943,6 +943,21 @@ TOOLTIPS_GetToolFromPoint (const TOOLTIPS_INFO *infoPtr, HWND hwnd, const POINT return -1; } +static inline void +TOOLTIPS_CopyInfoT (const TTTOOL_INFO *toolPtr, TTTOOLINFOW *ti, BOOL isW) +{ + if (ti->lpszText) { + if (toolPtr->lpszText == NULL || + IS_INTRESOURCE(toolPtr->lpszText) || + toolPtr->lpszText == LPSTR_TEXTCALLBACKW) + ti->lpszText = toolPtr->lpszText; + else if (isW) + strcpyW (ti->lpszText, toolPtr->lpszText); + else + WideCharToMultiByte(CP_ACP, 0, toolPtr->lpszText, -1, + (LPSTR)ti->lpszText, INFOTIPSIZE, NULL, NULL); + } +} static BOOL TOOLTIPS_IsWindowActive (HWND hwnd) @@ -1199,8 +1214,7 @@ TOOLTIPS_EnumToolsT (const TOOLTIPS_INFO *infoPtr, UINT uIndex, TTTOOLINFOW *ti, ti->uId = toolPtr->uId; ti->rect = toolPtr->rect; ti->hinst = toolPtr->hinst; -/* ti->lpszText = toolPtr->lpszText; */ - ti->lpszText = NULL; /* FIXME */ + TOOLTIPS_CopyInfoT (toolPtr, ti, isW); if (ti->cbSize >= TTTOOLINFOA_V2_SIZE) ti->lParam = toolPtr->lParam; @@ -1246,8 +1260,7 @@ TOOLTIPS_GetCurrentToolT (const TOOLTIPS_INFO *infoPtr, TTTOOLINFOW *ti, BOOL is ti->uFlags = toolPtr->uFlags; ti->rect = toolPtr->rect; ti->hinst = toolPtr->hinst; -/* ti->lpszText = toolPtr->lpszText; */ - ti->lpszText = NULL; /* FIXME */ + TOOLTIPS_CopyInfoT (toolPtr, ti, isW); if (ti->cbSize >= TTTOOLINFOW_V2_SIZE) ti->lParam = toolPtr->lParam; @@ -1385,8 +1398,7 @@ TOOLTIPS_GetToolInfoT (const TOOLTIPS_INFO *infoPtr, TTTOOLINFOW *ti, BOOL isW) ti->uFlags = toolPtr->uFlags; ti->rect = toolPtr->rect; ti->hinst = toolPtr->hinst; -/* lpToolInfo->lpszText = toolPtr->lpszText; */ - ti->lpszText = NULL; /* FIXME */ + TOOLTIPS_CopyInfoT (toolPtr, ti, isW); if (ti->cbSize >= TTTOOLINFOW_V2_SIZE) ti->lParam = toolPtr->lParam; @@ -1420,8 +1432,7 @@ TOOLTIPS_HitTestT (const TOOLTIPS_INFO *infoPtr, LPTTHITTESTINFOW lptthit, lptthit->ti.uId = toolPtr->uId; lptthit->ti.rect = toolPtr->rect; lptthit->ti.hinst = toolPtr->hinst; -/* lptthit->ti.lpszText = toolPtr->lpszText; */ - lptthit->ti.lpszText = NULL; /* FIXME */ + TOOLTIPS_CopyInfoT (toolPtr, &lptthit->ti, isW); if (lptthit->ti.cbSize >= TTTOOLINFOW_V2_SIZE) lptthit->ti.lParam = toolPtr->lParam; } -- 2.11.4.GIT