Commit a27db516 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

comctl32/listbox: Use helper to test for selected state on painting.

parent 54ee4db6
...@@ -491,7 +491,13 @@ static void LISTBOX_PaintItem( LB_DESCR *descr, HDC hdc, const RECT *rect, ...@@ -491,7 +491,13 @@ static void LISTBOX_PaintItem( LB_DESCR *descr, HDC hdc, const RECT *rect,
INT index, UINT action, BOOL ignoreFocus ) INT index, UINT action, BOOL ignoreFocus )
{ {
LB_ITEMDATA *item = NULL; LB_ITEMDATA *item = NULL;
if (index < descr->nb_items) item = &descr->items[index]; BOOL selected = FALSE;
if (index < descr->nb_items)
{
item = &descr->items[index];
selected = is_item_selected(descr, index);
}
if (IS_OWNERDRAW(descr)) if (IS_OWNERDRAW(descr))
{ {
...@@ -522,7 +528,8 @@ static void LISTBOX_PaintItem( LB_DESCR *descr, HDC hdc, const RECT *rect, ...@@ -522,7 +528,8 @@ static void LISTBOX_PaintItem( LB_DESCR *descr, HDC hdc, const RECT *rect,
dis.hDC = hdc; dis.hDC = hdc;
dis.itemID = index; dis.itemID = index;
dis.itemState = 0; dis.itemState = 0;
if (item->selected) dis.itemState |= ODS_SELECTED; if (selected)
dis.itemState |= ODS_SELECTED;
if (!ignoreFocus && (descr->focus_item == index) && if (!ignoreFocus && (descr->focus_item == index) &&
(descr->caret_on) && (descr->caret_on) &&
(descr->in_focus)) dis.itemState |= ODS_FOCUS; (descr->in_focus)) dis.itemState |= ODS_FOCUS;
...@@ -545,7 +552,7 @@ static void LISTBOX_PaintItem( LB_DESCR *descr, HDC hdc, const RECT *rect, ...@@ -545,7 +552,7 @@ static void LISTBOX_PaintItem( LB_DESCR *descr, HDC hdc, const RECT *rect,
DrawFocusRect( hdc, rect ); DrawFocusRect( hdc, rect );
return; return;
} }
if (item && item->selected) if (selected)
{ {
oldBk = SetBkColor( hdc, GetSysColor( COLOR_HIGHLIGHT ) ); oldBk = SetBkColor( hdc, GetSysColor( COLOR_HIGHLIGHT ) );
oldText = SetTextColor( hdc, GetSysColor(COLOR_HIGHLIGHTTEXT)); oldText = SetTextColor( hdc, GetSysColor(COLOR_HIGHLIGHTTEXT));
...@@ -570,7 +577,7 @@ static void LISTBOX_PaintItem( LB_DESCR *descr, HDC hdc, const RECT *rect, ...@@ -570,7 +577,7 @@ static void LISTBOX_PaintItem( LB_DESCR *descr, HDC hdc, const RECT *rect,
item->str, strlenW(item->str), item->str, strlenW(item->str),
descr->nb_tabs, descr->tabs, 0); descr->nb_tabs, descr->tabs, 0);
} }
if (item && item->selected) if (selected)
{ {
SetBkColor( hdc, oldBk ); SetBkColor( hdc, oldBk );
SetTextColor( hdc, oldText ); SetTextColor( hdc, oldText );
......
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