comctl32: Close previously selected treeview item at common ancestor.

Also, send WM_NOTIFY mesages when collapsing the previous selection and
expanding the new one.
This commit is contained in:
Alex Henrie 2015-05-17 23:36:25 -06:00 committed by Alexandre Julliard
parent 9f93080754
commit a0ebe244c4
2 changed files with 16 additions and 36 deletions

View File

@ -1767,9 +1767,9 @@ static void test_TVS_SINGLEEXPAND(void)
{
{ &alpha, parent_singleexpand_seq0, FALSE },
{ &bravo, parent_singleexpand_seq1, FALSE },
{ &delta, parent_singleexpand_seq2, TRUE },
{ &foxtrot, parent_singleexpand_seq3, TRUE },
{ &alpha, parent_singleexpand_seq4, TRUE },
{ &delta, parent_singleexpand_seq2, FALSE },
{ &foxtrot, parent_singleexpand_seq3, FALSE },
{ &alpha, parent_singleexpand_seq4, FALSE },
{ &golf, parent_singleexpand_seq5, TRUE },
{ &hotel, parent_singleexpand_seq6, FALSE },
{ &india, parent_singleexpand_seq7, FALSE },
@ -1801,12 +1801,8 @@ static void test_TVS_SINGLEEXPAND(void)
for (i = 0; i < sizeof(items)/sizeof(items[0]); i++)
{
ret = SendMessageA(hTree, TVM_GETITEMSTATE, (WPARAM)(*items[i].handle), 0xFFFF);
if (i == 0)
todo_wine ok(ret == items[i].final_state, "singleexpand items[%d]: expected state 0x%x got 0x%x\n",
i, items[i].final_state, ret);
else
ok(ret == items[i].final_state, "singleexpand items[%d]: expected state 0x%x got 0x%x\n",
i, items[i].final_state, ret);
ok(ret == items[i].final_state, "singleexpand items[%d]: expected state 0x%x got 0x%x\n",
i, items[i].final_state, ret);
}
/* a workaround for NT4 that sends expand notifications when nothing is about to expand */

View File

@ -29,7 +29,7 @@
*
* TODO:
* missing notifications: TVN_GETINFOTIP, TVN_KEYDOWN,
* TVN_SETDISPINFO, TVN_SINGLEEXPAND
* TVN_SETDISPINFO
*
* missing styles: TVS_FULLROWSELECT, TVS_INFOTIP, TVS_RTLREADING,
*
@ -3508,47 +3508,31 @@ TREEVIEW_Expand(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item,
static void TREEVIEW_SingleExpand(TREEVIEW_INFO *infoPtr,
HTREEITEM selection, HTREEITEM item)
{
TREEVIEW_ITEM *SelItem;
TREEVIEW_ITEM *prev, *curr;
if ((infoPtr->dwStyle & TVS_SINGLEEXPAND) == 0 || infoPtr->hwndEdit || !item) return;
TREEVIEW_SendTreeviewNotify(infoPtr, TVN_SINGLEEXPAND, TVC_UNKNOWN, TVIF_HANDLE | TVIF_PARAM, item, 0);
/*
* Close the previous selection all the way to the root
* as long as the new selection is not a child
* Close the previous item and its ancestors as long as they are not
* ancestors of the current item
*/
if(selection && (selection != item))
for (prev = selection; prev && TREEVIEW_ValidItem(infoPtr, prev); prev = prev->parent)
{
BOOL closeit = TRUE;
SelItem = item;
/* determine if the hitItem is a child of the currently selected item */
while(closeit && SelItem && TREEVIEW_ValidItem(infoPtr, SelItem) &&
(SelItem->parent != infoPtr->root))
for (curr = item; curr && TREEVIEW_ValidItem(infoPtr, curr); curr = curr->parent)
{
closeit = (SelItem != selection);
SelItem = SelItem->parent;
}
if(closeit)
{
if(TREEVIEW_ValidItem(infoPtr, selection))
SelItem = selection;
while(SelItem && (SelItem != item) && TREEVIEW_ValidItem(infoPtr, SelItem) &&
SelItem->parent != infoPtr->root)
{
TREEVIEW_Collapse(infoPtr, SelItem, FALSE, FALSE);
SelItem = SelItem->parent;
}
if (curr == prev)
goto finish;
}
TREEVIEW_Collapse(infoPtr, prev, FALSE, TRUE);
}
finish:
/*
* Expand the current item
*/
TREEVIEW_Expand(infoPtr, item, FALSE, FALSE);
TREEVIEW_Expand(infoPtr, item, FALSE, TRUE);
}
static BOOL