From 5507a073c5e1be9101440c110d2d1e7092a4d293 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Zalewski?= Date: Tue, 10 Jul 2007 15:53:38 +0200 Subject: [PATCH] comctl32: toolbar: We should send TBN_GETDISPINFOW even for ANSI controls (with testcase). --- dlls/comctl32/tests/toolbar.c | 21 ++++++++++++++++++++- dlls/comctl32/toolbar.c | 6 +++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/dlls/comctl32/tests/toolbar.c b/dlls/comctl32/tests/toolbar.c index 443e3eb65c1..f5476d3c035 100644 --- a/dlls/comctl32/tests/toolbar.c +++ b/dlls/comctl32/tests/toolbar.c @@ -74,6 +74,9 @@ static LRESULT MyWnd_Notify(LPARAM lParam) break; case TBN_GETDISPINFOA: + ok(FALSE, "TBN_GETDISPINFOA received\n"); + break; + case TBN_GETDISPINFOW: nmdisp = (NMTBDISPINFOA *)lParam; @@ -992,14 +995,30 @@ static void test_dispinfo(void) {-1, 20, TBSTATE_ENABLED, 0, {0, }, 0, -1}, {0, 21, TBSTATE_ENABLED, 0, {0, }, 0, -1}, }; + BOOL ret; rebuild_toolbar(&hToolbar); SendMessageA(hToolbar, TB_LOADIMAGES, IDB_HIST_SMALL_COLOR, (LPARAM)HINST_COMMCTRL); SendMessageA(hToolbar, TB_ADDBUTTONS, 2, (LPARAM)buttons_disp); g_dwExpectedDispInfoMask = 1; - /* some TBN_GETDISPINFO tests will be done in MyWnd_Notify function */ + /* Some TBN_GETDISPINFO tests will be done in MyWnd_Notify function. + * We will receive TBN_GETDISPINFOW even if the control is ANSI */ + compare((BOOL)SendMessageA(hToolbar, CCM_GETUNICODEFORMAT, 0, 0), 0, "%d"); ShowWindow(hToolbar, SW_SHOW); UpdateWindow(hToolbar); + + ret = (BOOL)SendMessageA(hToolbar, CCM_SETUNICODEFORMAT, TRUE, 0); + compare(ret, FALSE, "%d"); + compare(SendMessageA(hToolbar, CCM_GETUNICODEFORMAT, 0, 0), 1L, "%ld"); + InvalidateRect(hToolbar, NULL, FALSE); + UpdateWindow(hToolbar); + + ret = (BOOL)SendMessageA(hToolbar, CCM_SETUNICODEFORMAT, FALSE, 0); + compare(ret, TRUE, "%d"); + compare(SendMessageA(hToolbar, CCM_GETUNICODEFORMAT, 0, 0), 0L, "%ld"); + InvalidateRect(hToolbar, NULL, FALSE); + UpdateWindow(hToolbar); + DestroyWindow(hToolbar); g_dwExpectedDispInfoMask = 0; } diff --git a/dlls/comctl32/toolbar.c b/dlls/comctl32/toolbar.c index ec7b99d9808..da6ceab8ba2 100644 --- a/dlls/comctl32/toolbar.c +++ b/dlls/comctl32/toolbar.c @@ -360,15 +360,15 @@ TOOLBAR_GetBitmapIndex(const TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr) if (ret == I_IMAGECALLBACK) { /* issue TBN_GETDISPINFO */ - NMTBDISPINFOA nmgd; + NMTBDISPINFOW nmgd; memset(&nmgd, 0, sizeof(nmgd)); nmgd.idCommand = btnPtr->idCommand; nmgd.lParam = btnPtr->dwData; nmgd.dwMask = TBNF_IMAGE; nmgd.iImage = -1; - TOOLBAR_SendNotify(&nmgd.hdr, infoPtr, - infoPtr->bUnicode ? TBN_GETDISPINFOW : TBN_GETDISPINFOA); + /* Windows also send TBN_GETDISPINFOW even if the control is ANSI */ + TOOLBAR_SendNotify(&nmgd.hdr, infoPtr, TBN_GETDISPINFOW); if (nmgd.dwMask & TBNF_DI_SETITEM) btnPtr->iBitmap = nmgd.iImage; ret = nmgd.iImage;