Commit e98d4b45 authored by Gabriel Ivăncescu's avatar Gabriel Ivăncescu Committed by Alexandre Julliard

comctl32/listbox: Move the item data removal into a separate function.

parent bd2cc134
...@@ -200,6 +200,15 @@ static void insert_item_data(LB_DESCR *descr, UINT index, WCHAR *str, ULONG_PTR ...@@ -200,6 +200,15 @@ static void insert_item_data(LB_DESCR *descr, UINT index, WCHAR *str, ULONG_PTR
item->selected = FALSE; item->selected = FALSE;
} }
static void remove_item_data(LB_DESCR *descr, UINT index)
{
LB_ITEMDATA *item;
item = descr->items + index;
if (index < descr->nb_items)
memmove(item, item + 1, (descr->nb_items - index) * sizeof(LB_ITEMDATA));
}
/*********************************************************************** /***********************************************************************
* LISTBOX_GetCurrentPageSize * LISTBOX_GetCurrentPageSize
* *
...@@ -1699,8 +1708,6 @@ static void LISTBOX_DeleteItem( LB_DESCR *descr, INT index ) ...@@ -1699,8 +1708,6 @@ static void LISTBOX_DeleteItem( LB_DESCR *descr, INT index )
*/ */
static LRESULT LISTBOX_RemoveItem( LB_DESCR *descr, INT index ) static LRESULT LISTBOX_RemoveItem( LB_DESCR *descr, INT index )
{ {
LB_ITEMDATA *item;
if ((index < 0) || (index >= descr->nb_items)) return LB_ERR; if ((index < 0) || (index >= descr->nb_items)) return LB_ERR;
/* We need to invalidate the original rect instead of the updated one. */ /* We need to invalidate the original rect instead of the updated one. */
...@@ -1713,15 +1720,9 @@ static LRESULT LISTBOX_RemoveItem( LB_DESCR *descr, INT index ) ...@@ -1713,15 +1720,9 @@ static LRESULT LISTBOX_RemoveItem( LB_DESCR *descr, INT index )
} }
descr->nb_items--; descr->nb_items--;
LISTBOX_DeleteItem( descr, index ); LISTBOX_DeleteItem( descr, index );
remove_item_data(descr, index);
/* Remove the item */
item = &descr->items[index];
if (index < descr->nb_items)
RtlMoveMemory( item, item + 1,
(descr->nb_items - index) * sizeof(LB_ITEMDATA) );
if (descr->anchor_item == descr->nb_items) descr->anchor_item--; if (descr->anchor_item == descr->nb_items) descr->anchor_item--;
resize_storage(descr, descr->nb_items); resize_storage(descr, descr->nb_items);
/* Repaint the items */ /* Repaint the items */
......
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