[PATCH] comctl32/toolbar: Fix tooltip notification forwarding.
Nikolay Sivov
nsivov at codeweavers.com
Mon Apr 30 11:29:06 CDT 2018
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
dlls/comctl32/tests/toolbar.c | 3 +-
dlls/comctl32/toolbar.c | 59 +++++++++++++++++++++++++++++++----
2 files changed, 54 insertions(+), 8 deletions(-)
diff --git a/dlls/comctl32/tests/toolbar.c b/dlls/comctl32/tests/toolbar.c
index ce5eab3cc8..5fd6133e1f 100644
--- a/dlls/comctl32/tests/toolbar.c
+++ b/dlls/comctl32/tests/toolbar.c
@@ -56,7 +56,6 @@ static BOOL g_ResetDispTextPtr;
static const struct message ttgetdispinfo_parent_seq[] = {
{ WM_NOTIFY, sent|id, 0, 0, TBN_GETINFOTIPA },
- /* next line is todo, currently TTN_GETDISPINFOW is raised here */
{ WM_NOTIFY, sent|id, 0, 0, TTN_GETDISPINFOA },
{ 0 }
};
@@ -2026,7 +2025,7 @@ static void test_tooltip(void)
flush_sequences(sequences, NUM_MSG_SEQUENCES);
SendMessageA(hToolbar, WM_NOTIFY, 0, (LPARAM)&nmtti);
ok_sequence(sequences, PARENT_SEQ_INDEX, ttgetdispinfo_parent_seq,
- "dispinfo from tooltip", TRUE);
+ "dispinfo from tooltip", FALSE);
g_ResetDispTextPtr = TRUE;
SendMessageA(hToolbar, WM_NOTIFY, 0, (LPARAM)&nmtti);
diff --git a/dlls/comctl32/toolbar.c b/dlls/comctl32/toolbar.c
index cc708f0642..e1cb7b7169 100644
--- a/dlls/comctl32/toolbar.c
+++ b/dlls/comctl32/toolbar.c
@@ -6118,6 +6118,9 @@ TOOLBAR_NCPaint (HWND hwnd, WPARAM wParam, LPARAM lParam)
static LRESULT TOOLBAR_TTGetDispInfo (TOOLBAR_INFO *infoPtr, NMTTDISPINFOW *lpnmtdi)
{
int index = TOOLBAR_GetButtonIndex(infoPtr, lpnmtdi->hdr.idFrom, FALSE);
+ NMTTDISPINFOA nmtdi;
+ unsigned int len;
+ LRESULT ret;
TRACE("button index = %d\n", index);
@@ -6131,7 +6134,6 @@ static LRESULT TOOLBAR_TTGetDispInfo (TOOLBAR_INFO *infoPtr, NMTTDISPINFOW *lpnm
{
WCHAR wszBuffer[INFOTIPSIZE+1];
NMTBGETINFOTIPW tbgit;
- unsigned int len; /* in chars */
wszBuffer[0] = '\0';
wszBuffer[INFOTIPSIZE] = '\0';
@@ -6169,7 +6171,6 @@ static LRESULT TOOLBAR_TTGetDispInfo (TOOLBAR_INFO *infoPtr, NMTTDISPINFOW *lpnm
{
CHAR szBuffer[INFOTIPSIZE+1];
NMTBGETINFOTIPA tbgit;
- unsigned int len; /* in chars */
szBuffer[0] = '\0';
szBuffer[INFOTIPSIZE] = '\0';
@@ -6210,7 +6211,7 @@ static LRESULT TOOLBAR_TTGetDispInfo (TOOLBAR_INFO *infoPtr, NMTTDISPINFOW *lpnm
!(infoPtr->buttons[index].fsStyle & BTNS_SHOWTEXT))
{
LPWSTR pszText = TOOLBAR_GetText(infoPtr, &infoPtr->buttons[index]);
- unsigned int len = pszText ? strlenW(pszText) : 0;
+ len = pszText ? strlenW(pszText) : 0;
TRACE("using button hidden text %s\n", debugstr_w(pszText));
@@ -6236,9 +6237,55 @@ static LRESULT TOOLBAR_TTGetDispInfo (TOOLBAR_INFO *infoPtr, NMTTDISPINFOW *lpnm
TRACE("Sending tooltip notification to %p\n", infoPtr->hwndNotify);
- /* last resort: send notification on to app */
- /* FIXME: find out what is really used here */
- return SendMessageW(infoPtr->hwndNotify, WM_NOTIFY, lpnmtdi->hdr.idFrom, (LPARAM)lpnmtdi);
+ /* Last resort, forward TTN_GETDISPINFO to the app:
+
+ - NFR_UNICODE gets TTN_GETDISPINFOW, and TTN_GETDISPINFOA if -W returned no text;
+ - NFR_ANSI gets only TTN_GETDISPINFOA.
+ */
+ if (infoPtr->bUnicode)
+ {
+ ret = SendMessageW(infoPtr->hwndNotify, WM_NOTIFY, lpnmtdi->hdr.idFrom, (LPARAM)lpnmtdi);
+
+ TRACE("TTN_GETDISPINFOW - got string %s\n", debugstr_w(lpnmtdi->lpszText));
+
+ if (lpnmtdi->lpszText && *lpnmtdi->lpszText)
+ return ret;
+ }
+
+ nmtdi.hdr.hwndFrom = lpnmtdi->hdr.hwndFrom;
+ nmtdi.hdr.idFrom = lpnmtdi->hdr.idFrom;
+ nmtdi.hdr.code = TTN_GETDISPINFOA;
+ nmtdi.lpszText = nmtdi.szText;
+ nmtdi.szText[0] = 0;
+ nmtdi.hinst = lpnmtdi->hinst;
+ nmtdi.uFlags = lpnmtdi->uFlags;
+ nmtdi.lParam = lpnmtdi->lParam;
+
+ ret = SendMessageW(infoPtr->hwndNotify, WM_NOTIFY, nmtdi.hdr.idFrom, (LPARAM)&nmtdi);
+
+ TRACE("TTN_GETDISPINFOA - got string %s\n", debugstr_a(nmtdi.lpszText));
+
+ if (!nmtdi.lpszText || !*nmtdi.lpszText)
+ return ret;
+
+ len = MultiByteToWideChar(CP_ACP, 0, nmtdi.lpszText, -1, NULL, 0);
+ if (len > ARRAY_SIZE(lpnmtdi->szText))
+ {
+ infoPtr->pszTooltipText = Alloc(len * sizeof(WCHAR));
+ if (infoPtr->pszTooltipText)
+ {
+ MultiByteToWideChar(CP_ACP, 0, nmtdi.lpszText, -1, infoPtr->pszTooltipText, len);
+ lpnmtdi->lpszText = infoPtr->pszTooltipText;
+ return 0;
+ }
+ }
+ else
+ {
+ MultiByteToWideChar(CP_ACP, 0, nmtdi.lpszText, -1, lpnmtdi->lpszText, ARRAY_SIZE(nmtdi.szText));
+ return 0;
+ }
+
+ return ret;
}
--
2.17.0
More information about the wine-devel
mailing list