Commit 9d0ebc13 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

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

parent 75fc8913
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
#include <windows.h> #include <windows.h>
#include <commctrl.h> #include <commctrl.h>
#include "resources.h"
#include "wine/test.h" #include "wine/test.h"
#define expect(expected, got) ok(got == expected, "Expected %d, got %d\n", expected, got) #define expect(expected, got) ok(got == expected, "Expected %d, got %d\n", expected, got)
...@@ -326,6 +328,30 @@ static void test_gettext(void) ...@@ -326,6 +328,30 @@ static void test_gettext(void)
SendMessageA(hwnd, TTM_GETTOOLINFOA, 0, (LPARAM)&toolinfoA); SendMessageA(hwnd, TTM_GETTOOLINFOA, 0, (LPARAM)&toolinfoA);
ok(toolinfoA.lpszText == NULL, ok(toolinfoA.lpszText == NULL,
"expected NULL, got %p\n", toolinfoA.lpszText); "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 else
{ {
......
...@@ -484,12 +484,12 @@ TOOLTIPS_GetTipText (const TOOLTIPS_INFO *infoPtr, INT nTool, WCHAR *buffer) ...@@ -484,12 +484,12 @@ TOOLTIPS_GetTipText (const TOOLTIPS_INFO *infoPtr, INT nTool, WCHAR *buffer)
{ {
TTTOOL_INFO *toolPtr = &infoPtr->tools[nTool]; TTTOOL_INFO *toolPtr = &infoPtr->tools[nTool];
if (IS_INTRESOURCE(toolPtr->lpszText) && toolPtr->hinst) { if (IS_INTRESOURCE(toolPtr->lpszText)) {
/* load a resource */ /* load a resource */
TRACE("load res string %p %x\n", TRACE("load res string %p %x\n",
toolPtr->hinst, LOWORD(toolPtr->lpszText)); toolPtr->hinst, LOWORD(toolPtr->lpszText));
LoadStringW (toolPtr->hinst, LOWORD(toolPtr->lpszText), if (!LoadStringW (toolPtr->hinst, LOWORD(toolPtr->lpszText), buffer, INFOTIPSIZE))
buffer, INFOTIPSIZE); buffer[0] = '\0';
} }
else if (toolPtr->lpszText) { else if (toolPtr->lpszText) {
if (toolPtr->lpszText == LPSTR_TEXTCALLBACKW) { if (toolPtr->lpszText == LPSTR_TEXTCALLBACKW) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment