[PATCH 1/3] Properly initialize expanded image index. This fixes a regression from e81d65f8d45abf2dc304d4f841a09537395a57f3.
Nikolay Sivov
nsivov at codeweavers.com
Mon Jul 26 03:53:08 CDT 2010
---
dlls/comctl32/tests/treeview.c | 70 ++++++++++++++++++++++++++++++++++++++++
dlls/comctl32/treeview.c | 4 +-
2 files changed, 72 insertions(+), 2 deletions(-)
diff --git a/dlls/comctl32/tests/treeview.c b/dlls/comctl32/tests/treeview.c
index 18528e3..d3de85f 100644
--- a/dlls/comctl32/tests/treeview.c
+++ b/dlls/comctl32/tests/treeview.c
@@ -30,6 +30,7 @@
#include "commctrl.h"
#include "wine/test.h"
+#include "v6util.h"
#include "msg.h"
const char *TEST_CALLBACK_TEXT = "callback_text";
@@ -1191,12 +1192,55 @@ static void test_rect_retrieval_after_expand_with_select(void) {
ok(ret,"TreeView_Select should return true\n");
}
+static void test_expandedimage(void)
+{
+ TVITEMEX item;
+ HWND hTree;
+ BOOL ret;
+
+ hTree = create_treeview_control();
+ fill_tree(hTree);
+
+ item.mask = TVIF_EXPANDEDIMAGE;
+ item.iExpandedImage = 1;
+ item.hItem = hRoot;
+ ret = SendMessageA(hTree, TVM_SETITEM, 0, (LPARAM)&item);
+ ok(ret, "got %d\n", ret);
+
+ item.mask = TVIF_EXPANDEDIMAGE;
+ item.iExpandedImage = -1;
+ item.hItem = hRoot;
+ ret = SendMessageA(hTree, TVM_GETITEM, 0, (LPARAM)&item);
+ ok(ret, "got %d\n", ret);
+
+ if (item.iExpandedImage != 1)
+ {
+ win_skip("TVIF_EXPANDEDIMAGE not supported\n");
+ DestroyWindow(hTree);
+ return;
+ }
+
+ /* test for default iExpandedImage value */
+ item.mask = TVIF_EXPANDEDIMAGE;
+ item.iExpandedImage = -1;
+ item.hItem = hChild;
+ ret = SendMessageA(hTree, TVM_GETITEM, 0, (LPARAM)&item);
+ ok(ret, "got %d\n", ret);
+ ok(item.iExpandedImage == (WORD)I_IMAGENONE, "got %d\n", item.iExpandedImage);
+
+ DestroyWindow(hTree);
+}
+
START_TEST(treeview)
{
HMODULE hComctl32;
BOOL (WINAPI *pInitCommonControlsEx)(const INITCOMMONCONTROLSEX*);
WNDCLASSA wc;
MSG msg;
+
+ ULONG_PTR ctx_cookie;
+ HANDLE hCtx;
+ HWND hwnd;
hComctl32 = GetModuleHandleA("comctl32.dll");
pInitCommonControlsEx = (void*)GetProcAddress(hComctl32, "InitCommonControlsEx");
@@ -1253,6 +1297,32 @@ START_TEST(treeview)
test_expandnotify();
test_rect_retrieval_after_expand_with_select();
+ if (!load_v6_module(&ctx_cookie, &hCtx))
+ {
+ DestroyWindow(hMainWnd);
+ return;
+ }
+
+ /* this is a XP SP3 failure workaround */
+ hwnd = CreateWindowExA(0, WC_TREEVIEW, "foo",
+ WS_CHILD | WS_BORDER | WS_VISIBLE,
+ 0, 0, 100, 100,
+ hMainWnd, NULL, GetModuleHandleA(NULL), NULL);
+ if (!IsWindow(hwnd))
+ {
+ win_skip("FIXME: failed to create TreeView window.\n");
+ unload_v6_module(ctx_cookie, hCtx);
+ DestroyWindow(hMainWnd);
+ return;
+ }
+ else
+ DestroyWindow(hwnd);
+
+ /* comctl32 version 6 tests start here */
+ test_expandedimage();
+
+ unload_v6_module(ctx_cookie, hCtx);
+
PostMessageA(hMainWnd, WM_CLOSE, 0, 0);
while(GetMessageA(&msg,0,0,0)) {
TranslateMessage(&msg);
diff --git a/dlls/comctl32/treeview.c b/dlls/comctl32/treeview.c
index b49bbcd..8683b4a 100644
--- a/dlls/comctl32/treeview.c
+++ b/dlls/comctl32/treeview.c
@@ -1005,7 +1005,7 @@ TREEVIEW_AllocateItem(const TREEVIEW_INFO *infoPtr)
* inc/dec to toggle the images. */
newItem->iImage = 0;
newItem->iSelectedImage = 0;
- newItem->iExpandedImage = 0;
+ newItem->iExpandedImage = (WORD)I_IMAGENONE;
if (DPA_InsertPtr(infoPtr->items, INT_MAX, newItem) == -1)
{
@@ -2575,7 +2575,7 @@ TREEVIEW_DrawItem(const TREEVIEW_INFO *infoPtr, HDC hdc, TREEVIEW_ITEM *wineItem
/* The item is currently selected */
imageIndex = wineItem->iSelectedImage;
}
- else if ((wineItem->state & TVIS_EXPANDED) && (wineItem->iExpandedImage >= 0))
+ else if ((wineItem->state & TVIS_EXPANDED) && (wineItem->iExpandedImage != (WORD)I_IMAGENONE))
{
/* The item is currently not selected but expanded */
imageIndex = wineItem->iExpandedImage;
--
1.5.6.5
--------------070505030408090704010307--
More information about the wine-patches
mailing list