comctl32: toolbar[1/2]: the iImage in TBN_GETDISPINFO should be
initialized to -1 (with testcase, fixes bug #8828)
Mikołaj Zalewski
mikolaj at zalewski.pl
Tue Jul 10 09:12:32 CDT 2007
That way if the window proc doesn't handle the message the button will
have no image instead of the first image from the image list.
-------------- next part --------------
From 1f7ef4077bdd2fd971f372819d807ef3efe4aa46 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Miko=C5=82aj_Zalewski?= <mikolaj at zalewski.pl>
Date: Tue, 10 Jul 2007 15:23:05 +0200
Subject: [PATCH] comctl32: toolbar: the iImage in TBN_GETDISPINFO should be initialized to -1 (with testcase, fixes bug #8828)
---
dlls/comctl32/tests/toolbar.c | 31 +++++++++++++++++++++++++++++++
dlls/comctl32/toolbar.c | 1 +
2 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/dlls/comctl32/tests/toolbar.c b/dlls/comctl32/tests/toolbar.c
index 89e25a2..443e3eb 100644
--- a/dlls/comctl32/tests/toolbar.c
+++ b/dlls/comctl32/tests/toolbar.c
@@ -38,6 +38,7 @@ static BOOL g_fBlockHotItemChange;
static BOOL g_fReceivedHotItemChange;
static BOOL g_fExpectedHotItemOld;
static BOOL g_fExpectedHotItemNew;
+static DWORD g_dwExpectedDispInfoMask;
#define check_rect(name, val, exp) ok(val.top == exp.top && val.bottom == exp.bottom && \
val.left == exp.left && val.right == exp.right, "invalid rect (" name ") (%d,%d) (%d,%d) - expected (%d,%d) (%d,%d)\n", \
@@ -57,6 +58,7 @@ static LRESULT MyWnd_Notify(LPARAM lParam)
{
NMHDR *hdr = (NMHDR *)lParam;
NMTBHOTITEM *nmhi;
+ NMTBDISPINFO *nmdisp;
switch (hdr->code)
{
case TBN_HOTITEMCHANGE:
@@ -70,6 +72,15 @@ static LRESULT MyWnd_Notify(LPARAM lParam)
if (g_fBlockHotItemChange)
return 1;
break;
+
+ case TBN_GETDISPINFOA:
+ case TBN_GETDISPINFOW:
+ nmdisp = (NMTBDISPINFOA *)lParam;
+
+ compare(nmdisp->dwMask, g_dwExpectedDispInfoMask, "%x");
+ compare(nmdisp->iImage, -1, "%d");
+ ok(nmdisp->pszText == NULL, "pszText is not NULL\n");
+ break;
}
return 0;
}
@@ -974,6 +985,25 @@ static void test_createtoolbarex()
DestroyWindow(hToolbar);
}
+static void test_dispinfo(void)
+{
+ HWND hToolbar = NULL;
+ const TBBUTTON buttons_disp[] = {
+ {-1, 20, TBSTATE_ENABLED, 0, {0, }, 0, -1},
+ {0, 21, TBSTATE_ENABLED, 0, {0, }, 0, -1},
+ };
+
+ 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 */
+ ShowWindow(hToolbar, SW_SHOW);
+ UpdateWindow(hToolbar);
+ DestroyWindow(hToolbar);
+ g_dwExpectedDispInfoMask = 0;
+}
+
START_TEST(toolbar)
{
@@ -1007,6 +1037,7 @@ START_TEST(toolbar)
test_sizes();
test_getbuttoninfo();
test_createtoolbarex();
+ test_dispinfo();
PostQuitMessage(0);
while(GetMessageA(&msg,0,0,0)) {
diff --git a/dlls/comctl32/toolbar.c b/dlls/comctl32/toolbar.c
index 4b1e552..ec7b99d 100644
--- a/dlls/comctl32/toolbar.c
+++ b/dlls/comctl32/toolbar.c
@@ -366,6 +366,7 @@ TOOLBAR_GetBitmapIndex(const TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr)
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);
if (nmgd.dwMask & TBNF_DI_SETITEM)
--
1.4.4.2
More information about the wine-patches
mailing list