comctl32/listbox: Use a helper to set item height by index.

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:
Gabriel Ivăncescu 2019-02-20 12:04:57 +00:00 committed by Alexandre Julliard
parent 249c09f4b1
commit e0984d4013
1 changed files with 7 additions and 2 deletions

View File

@ -168,6 +168,11 @@ static UINT get_item_height( const LB_DESCR *descr, UINT index )
return (descr->style & LBS_NODATA) ? 0 : descr->items[index].height; return (descr->style & LBS_NODATA) ? 0 : descr->items[index].height;
} }
static void set_item_height( LB_DESCR *descr, UINT index, UINT height )
{
if (!(descr->style & LBS_NODATA)) descr->items[index].height = height;
}
static BOOL is_item_selected( const LB_DESCR *descr, UINT index ) static BOOL is_item_selected( const LB_DESCR *descr, UINT index )
{ {
if (!(descr->style & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL))) if (!(descr->style & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)))
@ -1233,7 +1238,7 @@ static LRESULT LISTBOX_SetItemHeight( LB_DESCR *descr, INT index, INT height, BO
return LB_ERR; return LB_ERR;
} }
TRACE("[%p]: item %d height = %d\n", descr->self, index, height ); TRACE("[%p]: item %d height = %d\n", descr->self, index, height );
descr->items[index].height = height; set_item_height(descr, index, height);
LISTBOX_UpdateScroll( descr ); LISTBOX_UpdateScroll( descr );
if (repaint) if (repaint)
LISTBOX_InvalidateItems( descr, index ); LISTBOX_InvalidateItems( descr, index );
@ -1590,7 +1595,7 @@ static LRESULT LISTBOX_InsertItem( LB_DESCR *descr, INT index,
mis.itemData = data; mis.itemData = data;
mis.itemHeight = descr->item_height; mis.itemHeight = descr->item_height;
SendMessageW( descr->owner, WM_MEASUREITEM, id, (LPARAM)&mis ); SendMessageW( descr->owner, WM_MEASUREITEM, id, (LPARAM)&mis );
item->height = mis.itemHeight ? mis.itemHeight : 1; set_item_height(descr, index, mis.itemHeight ? mis.itemHeight : 1);
TRACE("[%p]: measure item %d (%s) = %d\n", TRACE("[%p]: measure item %d (%s) = %d\n",
descr->self, index, str ? debugstr_w(str) : "", get_item_height(descr, index)); descr->self, index, str ? debugstr_w(str) : "", get_item_height(descr, index));
} }