Commit b3a61c13 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

comctl32/treeview: Properly initialize expanded image index.

parent 47d28ace
......@@ -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,6 +1192,45 @@ 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;
......@@ -1198,6 +1238,10 @@ START_TEST(treeview)
WNDCLASSA wc;
MSG msg;
ULONG_PTR ctx_cookie;
HANDLE hCtx;
HWND hwnd;
hComctl32 = GetModuleHandleA("comctl32.dll");
pInitCommonControlsEx = (void*)GetProcAddress(hComctl32, "InitCommonControlsEx");
if (pInitCommonControlsEx)
......@@ -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);
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment