Commit 5312cc6d authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

comctl32/tooltips: Return full toolinfo from TTM_GETCURRENTTOOL.

parent 096df5f5
...@@ -151,8 +151,8 @@ static void test_customdraw(void) { ...@@ -151,8 +151,8 @@ static void test_customdraw(void) {
DWORD iterationNumber; DWORD iterationNumber;
WNDCLASSA wc; WNDCLASSA wc;
LRESULT lResult;
POINT orig_pos; POINT orig_pos;
LRESULT ret;
/* Create a class to use the custom draw wndproc */ /* Create a class to use the custom draw wndproc */
wc.style = CS_HREDRAW | CS_VREDRAW; wc.style = CS_HREDRAW | CS_VREDRAW;
...@@ -216,8 +216,8 @@ static void test_customdraw(void) { ...@@ -216,8 +216,8 @@ static void test_customdraw(void) {
toolInfo.lpszText = (LPSTR)"This is a test tooltip"; toolInfo.lpszText = (LPSTR)"This is a test tooltip";
toolInfo.lParam = 0xdeadbeef; toolInfo.lParam = 0xdeadbeef;
GetClientRect (parent, &toolInfo.rect); GetClientRect (parent, &toolInfo.rect);
lResult = SendMessageA(hwndTip, TTM_ADDTOOLA, 0, (LPARAM)&toolInfo); ret = SendMessageA(hwndTip, TTM_ADDTOOLA, 0, (LPARAM)&toolInfo);
ok(lResult, "Adding the tool to the tooltip failed\n"); ok(ret, "Failed to add the tool.\n");
/* Make tooltip appear quickly */ /* Make tooltip appear quickly */
SendMessageA(hwndTip, TTM_SETDELAYTIME, TTDT_INITIAL, MAKELPARAM(1,0)); SendMessageA(hwndTip, TTM_SETDELAYTIME, TTDT_INITIAL, MAKELPARAM(1,0));
...@@ -236,6 +236,20 @@ static void test_customdraw(void) { ...@@ -236,6 +236,20 @@ static void test_customdraw(void) {
expectedResults[iterationNumber].ExpectedCalls); expectedResults[iterationNumber].ExpectedCalls);
} }
ret = SendMessageA(hwndTip, TTM_GETCURRENTTOOLA, 0, 0);
ok(ret, "Failed to get current tool %#lx.\n", ret);
memset(&toolInfo, 0xcc, sizeof(toolInfo));
toolInfo.cbSize = sizeof(toolInfo);
toolInfo.lpszText = NULL;
toolInfo.lpReserved = (void *)0xdeadbeef;
SendMessageA(hwndTip, TTM_GETCURRENTTOOLA, 0, (LPARAM)&toolInfo);
ok(toolInfo.hwnd == parent, "Unexpected hwnd %p.\n", toolInfo.hwnd);
ok(toolInfo.hinst == GetModuleHandleA(NULL), "Unexpected hinst %p.\n", toolInfo.hinst);
ok(toolInfo.uId == 0x1234abcd, "Unexpected uId %lx.\n", toolInfo.uId);
ok(toolInfo.lParam == 0, "Unexpected lParam %lx.\n", toolInfo.lParam);
ok(toolInfo.lpReserved == (void *)0xdeadbeef, "Unexpected lpReserved %p.\n", toolInfo.lpReserved);
/* Clean up */ /* Clean up */
DestroyWindow(hwndTip); DestroyWindow(hwndTip);
DestroyWindow(parent); DestroyWindow(parent);
...@@ -491,9 +505,8 @@ static void test_ttm_gettoolinfo(void) ...@@ -491,9 +505,8 @@ static void test_ttm_gettoolinfo(void)
HWND hwnd; HWND hwnd;
DWORD r; DWORD r;
hwnd = CreateWindowExA(0, TOOLTIPS_CLASSA, NULL, 0, hwnd = CreateWindowExA(0, TOOLTIPS_CLASSA, NULL, 0, 10, 10, 300, 100, NULL, NULL, NULL, 0);
10, 10, 300, 100, ok(hwnd != NULL, "Failed to create tooltip control.\n");
NULL, NULL, NULL, 0);
ti.cbSize = TTTOOLINFOA_V2_SIZE; ti.cbSize = TTTOOLINFOA_V2_SIZE;
ti.hwnd = NULL; ti.hwnd = NULL;
...@@ -611,11 +624,7 @@ static void test_ttm_gettoolinfo(void) ...@@ -611,11 +624,7 @@ static void test_ttm_gettoolinfo(void)
hwnd = CreateWindowExW(0, TOOLTIPS_CLASSW, NULL, 0, hwnd = CreateWindowExW(0, TOOLTIPS_CLASSW, NULL, 0,
10, 10, 300, 100, 10, 10, 300, 100,
NULL, NULL, NULL, 0); NULL, NULL, NULL, 0);
if(!hwnd) ok(hwnd != NULL, "Failed to create tooltip window.\n");
{
win_skip("CreateWindowExW() not supported. Skipping.\n");
return;
}
tiW.cbSize = TTTOOLINFOW_V1_SIZE - 1; tiW.cbSize = TTTOOLINFOW_V1_SIZE - 1;
tiW.hwnd = NULL; tiW.hwnd = NULL;
...@@ -757,11 +766,7 @@ static void test_longtextW(void) ...@@ -757,11 +766,7 @@ static void test_longtextW(void)
hwnd = CreateWindowExW(0, TOOLTIPS_CLASSW, NULL, 0, hwnd = CreateWindowExW(0, TOOLTIPS_CLASSW, NULL, 0,
10, 10, 300, 100, 10, 10, 300, 100,
NULL, NULL, NULL, 0); NULL, NULL, NULL, 0);
if(!hwnd) ok(hwnd != NULL, "Failed to create tooltip window.\n");
{
win_skip("CreateWindowExW() not supported. Skipping.\n");
return;
}
toolinfoW.cbSize = TTTOOLINFOW_V2_SIZE; toolinfoW.cbSize = TTTOOLINFOW_V2_SIZE;
toolinfoW.hwnd = NULL; toolinfoW.hwnd = NULL;
......
...@@ -953,8 +953,16 @@ TOOLTIPS_GetToolFromPoint (const TOOLTIPS_INFO *infoPtr, HWND hwnd, const POINT ...@@ -953,8 +953,16 @@ TOOLTIPS_GetToolFromPoint (const TOOLTIPS_INFO *infoPtr, HWND hwnd, const POINT
} }
static inline void static inline void
TOOLTIPS_CopyInfoT (const TTTOOL_INFO *toolPtr, TTTOOLINFOW *ti, BOOL isW) TOOLTIPS_CopyInfoT (const TOOLTIPS_INFO *infoPtr, INT index, TTTOOLINFOW *ti, BOOL isW)
{ {
const TTTOOL_INFO *toolPtr = &infoPtr->tools[index];
ti->uFlags = toolPtr->uFlags;
ti->hwnd = toolPtr->hwnd;
ti->uId = toolPtr->uId;
ti->rect = toolPtr->rect;
ti->hinst = toolPtr->hinst;
if (ti->lpszText) { if (ti->lpszText) {
if (toolPtr->lpszText == NULL || if (toolPtr->lpszText == NULL ||
IS_INTRESOURCE(toolPtr->lpszText) || IS_INTRESOURCE(toolPtr->lpszText) ||
...@@ -967,6 +975,11 @@ TOOLTIPS_CopyInfoT (const TTTOOL_INFO *toolPtr, TTTOOLINFOW *ti, BOOL isW) ...@@ -967,6 +975,11 @@ TOOLTIPS_CopyInfoT (const TTTOOL_INFO *toolPtr, TTTOOLINFOW *ti, BOOL isW)
WideCharToMultiByte(CP_ACP, 0, toolPtr->lpszText, -1, WideCharToMultiByte(CP_ACP, 0, toolPtr->lpszText, -1,
(LPSTR)ti->lpszText, MAX_TEXT_SIZE_A, NULL, NULL); (LPSTR)ti->lpszText, MAX_TEXT_SIZE_A, NULL, NULL);
} }
if (ti->cbSize >= TTTOOLINFOW_V2_SIZE)
ti->lParam = toolPtr->lParam;
/* lpReserved is intentionally not set. */
} }
static BOOL static BOOL
...@@ -1220,28 +1233,14 @@ static LRESULT ...@@ -1220,28 +1233,14 @@ static LRESULT
TOOLTIPS_EnumToolsT (const TOOLTIPS_INFO *infoPtr, UINT uIndex, TTTOOLINFOW *ti, TOOLTIPS_EnumToolsT (const TOOLTIPS_INFO *infoPtr, UINT uIndex, TTTOOLINFOW *ti,
BOOL isW) BOOL isW)
{ {
TTTOOL_INFO *toolPtr; if (!ti || ti->cbSize < TTTOOLINFOW_V1_SIZE)
if (!ti) return FALSE;
if (ti->cbSize < TTTOOLINFOW_V1_SIZE)
return FALSE; return FALSE;
if (uIndex >= infoPtr->uNumTools) if (uIndex >= infoPtr->uNumTools)
return FALSE; return FALSE;
TRACE("index=%u\n", uIndex); TRACE("index=%u\n", uIndex);
toolPtr = &infoPtr->tools[uIndex]; TOOLTIPS_CopyInfoT (infoPtr, uIndex, ti, isW);
/* copy tool data */
ti->uFlags = toolPtr->uFlags;
ti->hwnd = toolPtr->hwnd;
ti->uId = toolPtr->uId;
ti->rect = toolPtr->rect;
ti->hinst = toolPtr->hinst;
TOOLTIPS_CopyInfoT (toolPtr, ti, isW);
if (ti->cbSize >= TTTOOLINFOA_V2_SIZE)
ti->lParam = toolPtr->lParam;
return TRUE; return TRUE;
} }
...@@ -1271,31 +1270,15 @@ TOOLTIPS_GetBubbleSize (const TOOLTIPS_INFO *infoPtr, const TTTOOLINFOW *lpToolI ...@@ -1271,31 +1270,15 @@ TOOLTIPS_GetBubbleSize (const TOOLTIPS_INFO *infoPtr, const TTTOOLINFOW *lpToolI
static LRESULT static LRESULT
TOOLTIPS_GetCurrentToolT (const TOOLTIPS_INFO *infoPtr, TTTOOLINFOW *ti, BOOL isW) TOOLTIPS_GetCurrentToolT (const TOOLTIPS_INFO *infoPtr, TTTOOLINFOW *ti, BOOL isW)
{ {
TTTOOL_INFO *toolPtr;
if (ti) { if (ti) {
if (ti->cbSize < TTTOOLINFOW_V1_SIZE) if (ti->cbSize < TTTOOLINFOW_V1_SIZE)
return FALSE; return FALSE;
if (infoPtr->nCurrentTool > -1) { if (infoPtr->nCurrentTool != -1)
toolPtr = &infoPtr->tools[infoPtr->nCurrentTool]; TOOLTIPS_CopyInfoT (infoPtr, infoPtr->nCurrentTool, ti, isW);
/* copy tool data */
ti->uFlags = toolPtr->uFlags;
ti->rect = toolPtr->rect;
ti->hinst = toolPtr->hinst;
TOOLTIPS_CopyInfoT (toolPtr, ti, isW);
if (ti->cbSize >= TTTOOLINFOW_V2_SIZE)
ti->lParam = toolPtr->lParam;
return TRUE;
}
else
return FALSE;
} }
else
return (infoPtr->nCurrentTool != -1); return infoPtr->nCurrentTool != -1;
} }
...@@ -1400,8 +1383,8 @@ TOOLTIPS_GetToolCount (const TOOLTIPS_INFO *infoPtr) ...@@ -1400,8 +1383,8 @@ TOOLTIPS_GetToolCount (const TOOLTIPS_INFO *infoPtr)
static LRESULT static LRESULT
TOOLTIPS_GetToolInfoT (const TOOLTIPS_INFO *infoPtr, TTTOOLINFOW *ti, BOOL isW) TOOLTIPS_GetToolInfoT (const TOOLTIPS_INFO *infoPtr, TTTOOLINFOW *ti, BOOL isW)
{ {
TTTOOL_INFO *toolPtr;
INT nTool; INT nTool;
HWND hwnd;
if (!ti) return FALSE; if (!ti) return FALSE;
if (ti->cbSize < TTTOOLINFOW_V1_SIZE) if (ti->cbSize < TTTOOLINFOW_V1_SIZE)
...@@ -1415,16 +1398,9 @@ TOOLTIPS_GetToolInfoT (const TOOLTIPS_INFO *infoPtr, TTTOOLINFOW *ti, BOOL isW) ...@@ -1415,16 +1398,9 @@ TOOLTIPS_GetToolInfoT (const TOOLTIPS_INFO *infoPtr, TTTOOLINFOW *ti, BOOL isW)
TRACE("tool %d\n", nTool); TRACE("tool %d\n", nTool);
toolPtr = &infoPtr->tools[nTool]; hwnd = ti->hwnd;
TOOLTIPS_CopyInfoT (infoPtr, nTool, ti, isW);
/* copy tool data */ ti->hwnd = hwnd;
ti->uFlags = toolPtr->uFlags;
ti->rect = toolPtr->rect;
ti->hinst = toolPtr->hinst;
TOOLTIPS_CopyInfoT (toolPtr, ti, isW);
if (ti->cbSize >= TTTOOLINFOW_V2_SIZE)
ti->lParam = toolPtr->lParam;
return TRUE; return TRUE;
} }
...@@ -1434,7 +1410,6 @@ static LRESULT ...@@ -1434,7 +1410,6 @@ static LRESULT
TOOLTIPS_HitTestT (const TOOLTIPS_INFO *infoPtr, LPTTHITTESTINFOW lptthit, TOOLTIPS_HitTestT (const TOOLTIPS_INFO *infoPtr, LPTTHITTESTINFOW lptthit,
BOOL isW) BOOL isW)
{ {
TTTOOL_INFO *toolPtr;
INT nTool; INT nTool;
if (lptthit == 0) if (lptthit == 0)
...@@ -1447,18 +1422,8 @@ TOOLTIPS_HitTestT (const TOOLTIPS_INFO *infoPtr, LPTTHITTESTINFOW lptthit, ...@@ -1447,18 +1422,8 @@ TOOLTIPS_HitTestT (const TOOLTIPS_INFO *infoPtr, LPTTHITTESTINFOW lptthit,
TRACE("tool %d!\n", nTool); TRACE("tool %d!\n", nTool);
/* copy tool data */ /* copy tool data */
if (lptthit->ti.cbSize >= TTTOOLINFOW_V1_SIZE) { if (lptthit->ti.cbSize >= TTTOOLINFOW_V1_SIZE)
toolPtr = &infoPtr->tools[nTool]; TOOLTIPS_CopyInfoT (infoPtr, nTool, &lptthit->ti, isW);
lptthit->ti.uFlags = toolPtr->uFlags;
lptthit->ti.hwnd = toolPtr->hwnd;
lptthit->ti.uId = toolPtr->uId;
lptthit->ti.rect = toolPtr->rect;
lptthit->ti.hinst = toolPtr->hinst;
TOOLTIPS_CopyInfoT (toolPtr, &lptthit->ti, isW);
if (lptthit->ti.cbSize >= TTTOOLINFOW_V2_SIZE)
lptthit->ti.lParam = toolPtr->lParam;
}
return TRUE; return TRUE;
} }
......
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