comctl32:toolbar: Correct tooltip text retrieval for toolbar buttons
Oleg Krylov
oleg.krylov at gmail.com
Thu Jul 27 08:07:49 CDT 2006
comctl32:toolbar: Correct tooltip text retrieval for toolbar buttons
changelog: 27.07.2006. by Oleg Krylov <oleg.krylov at gmail.com>
If toolbar is not unicode and application is not supporting
TBN_GETINFOTIP message no tooltip is show.
This patch fixes this an 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 not
BTNS_SHOWTEXT style tooltip is button text.
This order was got observing Windows XP behavior.
===============
diff -urN wine/dlls/comctl32/toolbar.c wineNew/dlls/comctl32/toolbar.c
--- wine/dlls/comctl32/toolbar.c 2006-05-23 15:47:38.000000000 +0300
+++ wineNew/dlls/comctl32/toolbar.c 2006-07-27 12:57:35.000000000 +0300
@@ -696,8 +696,9 @@
draw_masked = TRUE;
}
}
- else if ((tbcd->nmcd.uItemState & CDIS_HOT)
- && ((infoPtr->dwStyle & TBSTYLE_FLAT) || GetWindowTheme
(infoPtr->hwndSelf)))
+ else if (tbcd->nmcd.uItemState & CDIS_CHECKED ||
+ ((tbcd->nmcd.uItemState & CDIS_HOT)
+ && ((infoPtr->dwStyle & TBSTYLE_FLAT) || GetWindowTheme
(infoPtr->hwndSelf))))
{
/* if hot, attempt to draw with hot image list, if fails,
use default image list */
~/documents/pkg/~tmp$
~/documents/pkg/~tmp$ diff -urN wine/ wineNew/
~/documents/pkg/~tmp$ diff -urN wine/ wineNew/ > patch3.diff
~/documents/pkg/~tmp$ cat patch3.diff
diff -urN wine/dlls/comctl32/toolbar.c wineNew/dlls/comctl32/toolbar.c
--- wine/dlls/comctl32/toolbar.c 2006-05-23 15:47:38.000000000 +0300
+++ wineNew/dlls/comctl32/toolbar.c 2006-07-27 13:12:35.000000000 +0300
@@ -6544,11 +6544,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';
@@ -6577,17 +6582,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]);
@@ -6615,11 +6664,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