[RESEND 2] comctl32:toolbar: Correct tooltip text retrieval for
toolbar buttons
Oleg Krylov
oleg.krylov at gmail.com
Thu Aug 24 08:35:06 CDT 2006
Hello,
RESEND: added changelog and license
This patch adresses issue with an incorrect tooltip text retrieval in
toolbar code.
If toolbar is not unicode and application is not supporting
TBN_GETINFOTIP message, no tooltip is show.
This patch fixes this and also fixes order of tooltip text retrieval.
Correct order is TBN_GETINFOTIP[A/W], TTN_GETDISPINFO[A/W], and then
if toolbar has styles
TBSTYLE_LIST and TBSTYLE_EX_MIXEDBUTTONS and buttons has no
BTNS_SHOWTEXT style tooltip is button text.
Behavior matches native one, as observed on Windows XP.
Changelog:
- Correct tooltip text retrieval for toolbar buttons
Author: Oleg Krylov <oleg.krylov at gmail.com>
License: LGPL
-------------- next part --------------
diff -urN wineCVS/dlls/comctl32/toolbar.c wineTMP/dlls/comctl32/toolbar.c
--- wineCVS/dlls/comctl32/toolbar.c 2006-08-21 15:08:11.000000000 +0300
+++ wineTMP/dlls/comctl32/toolbar.c 2006-08-21 15:13:37.000000000 +0300
@@ -6545,11 +6545,16 @@
memcpy(lpnmtdi->lpszText, tbgit.pszText, (len+1)*sizeof(WCHAR));
return 0;
}
+
+ /* failed using TBN_GETINFOTIPW; try TTN_GETDISPINFOW then */
+ SendMessageW(infoPtr->hwndNotify, WM_NOTIFY, 0, (LPARAM)lpnmtdi);
+ if (IS_INTRESOURCE(lpnmtdi->lpszText) || lpnmtdi->lpszText[0] != '\0') return 0;
}
else
{
CHAR szBuffer[INFOTIPSIZE+1];
NMTBGETINFOTIPA tbgit;
+ NMTTDISPINFOA ttnmdi;
unsigned int len; /* in chars */
szBuffer[0] = '\0';
@@ -6578,17 +6583,61 @@
return 0;
}
}
- else if (len > 0)
+ else if (len > 1)
{
MultiByteToWideChar(CP_ACP, 0, tbgit.pszText, -1,
lpnmtdi->lpszText, sizeof(lpnmtdi->szText)/sizeof(lpnmtdi->szText[0]));
return 0;
}
+
+ /* failed using TBN_GETINFOTIPA; try TTN_GETDISPINFOA then */
+ ZeroMemory (&ttnmdi, sizeof(NMTTDISPINFOA));
+ ttnmdi.hdr.hwndFrom = lpnmtdi->hdr.hwndFrom;
+ ttnmdi.hdr.idFrom = lpnmtdi->hdr.idFrom;
+ ttnmdi.hdr.code = TTN_GETDISPINFOA;
+ ttnmdi.lpszText = (LPSTR)&ttnmdi.szText;
+ ttnmdi.uFlags = lpnmtdi->uFlags;
+ ttnmdi.lParam = lpnmtdi->lParam;
+
+ SendMessageW(infoPtr->hwndNotify, WM_NOTIFY, 0, (LPARAM)&ttnmdi);
+ if (IS_INTRESOURCE(ttnmdi.lpszText))
+ {
+ lpnmtdi->lpszText = (LPWSTR)ttnmdi.lpszText;
+ lpnmtdi->hinst = ttnmdi.hinst;
+ lpnmtdi->uFlags = ttnmdi.uFlags;
+ return 0;
+ }
+ if (ttnmdi.lpszText[0] != '\0')
+ {
+ lpnmtdi->uFlags = ttnmdi.uFlags;
+ lpnmtdi->lParam = ttnmdi.lParam;
+
+ len = MultiByteToWideChar(CP_ACP, 0, ttnmdi.lpszText, -1, NULL, 0);
+ if (len > sizeof(lpnmtdi->szText)/sizeof(lpnmtdi->szText[0]))
+ {
+ /* need to allocate temporary buffer in infoPtr as there
+ * isn't enough space in buffer passed to us by the
+ * tooltip control */
+ infoPtr->pszTooltipText = Alloc(len*sizeof(WCHAR));
+ if (infoPtr->pszTooltipText)
+ {
+ MultiByteToWideChar(CP_ACP, 0, ttnmdi.lpszText, -1, infoPtr->pszTooltipText, len);
+ lpnmtdi->lpszText = infoPtr->pszTooltipText;
+ return 0;
+ }
+ }
+ else if (len > 1)
+ {
+ MultiByteToWideChar(CP_ACP, 0, ttnmdi.lpszText, -1,
+ lpnmtdi->lpszText, sizeof(lpnmtdi->szText)/sizeof(lpnmtdi->szText[0]));
+ return 0;
+ }
+ }
}
/* if button has text, but it is not shown then automatically
* use that text as tooltip */
- if ((infoPtr->dwExStyle & TBSTYLE_EX_MIXEDBUTTONS) &&
+ if ((infoPtr->dwStyle & TBSTYLE_LIST) && (infoPtr->dwExStyle & TBSTYLE_EX_MIXEDBUTTONS) &&
!(infoPtr->buttons[index].fsStyle & BTNS_SHOWTEXT))
{
LPWSTR pszText = TOOLBAR_GetText(infoPtr, &infoPtr->buttons[index]);
@@ -6616,11 +6665,7 @@
}
}
- 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, 0, (LPARAM)lpnmtdi);
+ return 0;
}
More information about the wine-patches
mailing list