comctl32/tooltips: Allow NULL hinst value when fetching text from resources.

This commit is contained in:
Nikolay Sivov 2015-03-24 00:10:06 +03:00 committed by Alexandre Julliard
parent 75fc891340
commit 9d0ebc13ac
2 changed files with 29 additions and 3 deletions

View File

@ -20,6 +20,8 @@
#include <windows.h>
#include <commctrl.h>
#include "resources.h"
#include "wine/test.h"
#define expect(expected, got) ok(got == expected, "Expected %d, got %d\n", expected, got)
@ -326,6 +328,30 @@ static void test_gettext(void)
SendMessageA(hwnd, TTM_GETTOOLINFOA, 0, (LPARAM)&toolinfoA);
ok(toolinfoA.lpszText == NULL,
"expected NULL, got %p\n", toolinfoA.lpszText);
/* NULL hinst, valid resource id for text */
toolinfoA.cbSize = sizeof(TTTOOLINFOA);
toolinfoA.hwnd = NULL;
toolinfoA.hinst = NULL;
toolinfoA.uFlags = 0;
toolinfoA.uId = 0x1233ABCD;
toolinfoA.lpszText = MAKEINTRESOURCEA(IDS_TBADD1);
toolinfoA.lParam = 0xdeadbeef;
GetClientRect(hwnd, &toolinfoA.rect);
r = SendMessageA(hwnd, TTM_ADDTOOLA, 0, (LPARAM)&toolinfoA);
ok(r, "failed to add a tool\n");
toolinfoA.hwnd = NULL;
toolinfoA.uId = 0x1233ABCD;
toolinfoA.lpszText = bufA;
SendMessageA(hwnd, TTM_GETTEXTA, 0, (LPARAM)&toolinfoA);
ok(strcmp(toolinfoA.lpszText, "abc") == 0, "lpszText should be an empty string\n");
toolinfoA.hinst = (HINSTANCE)0xdeadbee;
SendMessageA(hwnd, TTM_GETTOOLINFOA, 0, (LPARAM)&toolinfoA);
ok(toolinfoA.hinst == NULL, "expected NULL, got %p\n", toolinfoA.hinst);
SendMessageA(hwnd, TTM_DELTOOLA, 0, (LPARAM)&toolinfoA);
}
else
{

View File

@ -484,12 +484,12 @@ TOOLTIPS_GetTipText (const TOOLTIPS_INFO *infoPtr, INT nTool, WCHAR *buffer)
{
TTTOOL_INFO *toolPtr = &infoPtr->tools[nTool];
if (IS_INTRESOURCE(toolPtr->lpszText) && toolPtr->hinst) {
if (IS_INTRESOURCE(toolPtr->lpszText)) {
/* load a resource */
TRACE("load res string %p %x\n",
toolPtr->hinst, LOWORD(toolPtr->lpszText));
LoadStringW (toolPtr->hinst, LOWORD(toolPtr->lpszText),
buffer, INFOTIPSIZE);
if (!LoadStringW (toolPtr->hinst, LOWORD(toolPtr->lpszText), buffer, INFOTIPSIZE))
buffer[0] = '\0';
}
else if (toolPtr->lpszText) {
if (toolPtr->lpszText == LPSTR_TEXTCALLBACKW) {