user32/listbox: Send LB_RESETCONTENT from RemoveItem rather than DeleteItem.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com> Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
84ac6eebaa
commit
0beea9f474
|
@ -1665,19 +1665,12 @@ static LRESULT LISTBOX_InsertString( LB_DESCR *descr, INT index, LPCWSTR str )
|
||||||
*/
|
*/
|
||||||
static void LISTBOX_DeleteItem( LB_DESCR *descr, INT index )
|
static void LISTBOX_DeleteItem( LB_DESCR *descr, INT index )
|
||||||
{
|
{
|
||||||
/* save the item data before it gets freed by LB_RESETCONTENT */
|
|
||||||
ULONG_PTR item_data = get_item_data(descr, index);
|
|
||||||
LPWSTR item_str = get_item_string(descr, index);
|
|
||||||
|
|
||||||
if (!descr->nb_items)
|
|
||||||
SendMessageW( descr->self, LB_RESETCONTENT, 0, 0 );
|
|
||||||
|
|
||||||
/* Note: Win 3.1 only sends DELETEITEM on owner-draw items,
|
/* Note: Win 3.1 only sends DELETEITEM on owner-draw items,
|
||||||
* while Win95 sends it for all items with user data.
|
* while Win95 sends it for all items with user data.
|
||||||
* It's probably better to send it too often than not
|
* It's probably better to send it too often than not
|
||||||
* often enough, so this is what we do here.
|
* often enough, so this is what we do here.
|
||||||
*/
|
*/
|
||||||
if (IS_OWNERDRAW(descr) || item_data)
|
if (IS_OWNERDRAW(descr) || get_item_data(descr, index))
|
||||||
{
|
{
|
||||||
DELETEITEMSTRUCT dis;
|
DELETEITEMSTRUCT dis;
|
||||||
UINT id = (UINT)GetWindowLongPtrW( descr->self, GWLP_ID );
|
UINT id = (UINT)GetWindowLongPtrW( descr->self, GWLP_ID );
|
||||||
|
@ -1686,10 +1679,10 @@ static void LISTBOX_DeleteItem( LB_DESCR *descr, INT index )
|
||||||
dis.CtlID = id;
|
dis.CtlID = id;
|
||||||
dis.itemID = index;
|
dis.itemID = index;
|
||||||
dis.hwndItem = descr->self;
|
dis.hwndItem = descr->self;
|
||||||
dis.itemData = item_data;
|
dis.itemData = get_item_data(descr, index);
|
||||||
SendMessageW( descr->owner, WM_DELETEITEM, id, (LPARAM)&dis );
|
SendMessageW( descr->owner, WM_DELETEITEM, id, (LPARAM)&dis );
|
||||||
}
|
}
|
||||||
HeapFree( GetProcessHeap(), 0, item_str );
|
HeapFree( GetProcessHeap(), 0, get_item_string(descr, index) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1707,11 +1700,14 @@ static LRESULT LISTBOX_RemoveItem( LB_DESCR *descr, INT index )
|
||||||
/* We need to invalidate the original rect instead of the updated one. */
|
/* We need to invalidate the original rect instead of the updated one. */
|
||||||
LISTBOX_InvalidateItems( descr, index );
|
LISTBOX_InvalidateItems( descr, index );
|
||||||
|
|
||||||
|
if (descr->nb_items == 1)
|
||||||
|
{
|
||||||
|
SendMessageW(descr->self, LB_RESETCONTENT, 0, 0);
|
||||||
|
return LB_OKAY;
|
||||||
|
}
|
||||||
descr->nb_items--;
|
descr->nb_items--;
|
||||||
LISTBOX_DeleteItem( descr, index );
|
LISTBOX_DeleteItem( descr, index );
|
||||||
|
|
||||||
if (!descr->nb_items) return LB_OKAY;
|
|
||||||
|
|
||||||
/* Remove the item */
|
/* Remove the item */
|
||||||
|
|
||||||
item = &descr->items[index];
|
item = &descr->items[index];
|
||||||
|
|
Loading…
Reference in New Issue