Send TVN_ITEMEXPANDING when the user tries to expand a tree item
_before_ checking for child items.
diff --git a/dlls/comctl32/treeview.c b/dlls/comctl32/treeview.c
index e11c848..d1478a1 100644
--- a/dlls/comctl32/treeview.c
+++ b/dlls/comctl32/treeview.c
@@ -3123,12 +3123,15 @@
TRACE("TVE_COLLAPSE %p %s\n", wineItem, TREEVIEW_ItemName(wineItem));
- if (!(wineItem->state & TVIS_EXPANDED) || wineItem->firstChild == NULL)
+ if (!(wineItem->state & TVIS_EXPANDED))
return FALSE;
if (bUser)
TREEVIEW_SendExpanding(infoPtr, wineItem, action);
+ if (wineItem->firstChild == NULL)
+ return FALSE;
+
wineItem->state &= ~TVIS_EXPANDED;
if (bUser)
@@ -3188,8 +3191,7 @@
{
TRACE("\n");
- if (!TREEVIEW_HasChildren(infoPtr, wineItem)
- || wineItem->state & TVIS_EXPANDED)
+ if (wineItem->state & TVIS_EXPANDED)
return FALSE;
TRACE("TVE_EXPAND %p %s\n", wineItem, TREEVIEW_ItemName(wineItem));
@@ -3202,12 +3204,18 @@
return FALSE;
}
+ if (!wineItem->firstChild)
+ return FALSE;
+
wineItem->state |= TVIS_EXPANDED;
TREEVIEW_SendExpanded(infoPtr, wineItem, TVE_EXPAND);
wineItem->state |= TVIS_EXPANDEDONCE;
}
else
{
+ if (!wineItem->firstChild)
+ return FALSE;
+
/* this item has already been expanded */
wineItem->state |= TVIS_EXPANDED;
}