TreeView - minor bugfix and optimization:
- GetDC call moved down to avoid possible resource leak. - Invariant code is moved out of loop.
This commit is contained in:
parent
40cd846356
commit
39ec6e48f9
|
@ -1055,7 +1055,7 @@ TREEVIEW_Refresh (HWND hwnd, HDC hdc)
|
|||
TEXTMETRICA tm;
|
||||
HBRUSH hbrBk;
|
||||
RECT rect;
|
||||
INT iItem, indent, x, y, cx, height, itemHeight;
|
||||
INT iItem, indent, x, y, height, itemHeight;
|
||||
INT viewtop,viewbottom,viewleft,viewright;
|
||||
TREEVIEW_ITEM *wineItem, *prevItem;
|
||||
|
||||
|
@ -1071,8 +1071,9 @@ TREEVIEW_Refresh (HWND hwnd, HDC hdc)
|
|||
GetClientRect (hwnd, &rect);
|
||||
if ((rect.left-rect.right ==0) || (rect.top-rect.bottom==0)) return;
|
||||
|
||||
infoPtr->cdmode=TREEVIEW_SendCustomDrawNotify
|
||||
(hwnd, CDDS_PREPAINT, hdc, rect);
|
||||
hdc=GetDC (hwnd);
|
||||
|
||||
infoPtr->cdmode=TREEVIEW_SendCustomDrawNotify(hwnd,CDDS_PREPAINT,hdc,rect);
|
||||
|
||||
if (infoPtr->cdmode==CDRF_SKIPDEFAULT) return;
|
||||
|
||||
|
@ -1084,25 +1085,15 @@ TREEVIEW_Refresh (HWND hwnd, HDC hdc)
|
|||
viewleft=infoPtr->cx;
|
||||
viewright=infoPtr->cx + rect.right-rect.left;
|
||||
|
||||
TRACE("[%d %d %d %d]\n",viewtop,viewbottom,viewleft,viewright);
|
||||
|
||||
/* draw background */
|
||||
|
||||
hbrBk = CreateSolidBrush (infoPtr->clrBk);
|
||||
FillRect(hdc, &rect, hbrBk);
|
||||
DeleteObject(hbrBk);
|
||||
|
||||
iItem=(INT)infoPtr->TopRootItem;
|
||||
infoPtr->firstVisible=0;
|
||||
wineItem=NULL;
|
||||
indent=0;
|
||||
x=y=0;
|
||||
TRACE("[%d %d %d %d]\n",viewtop,viewbottom,viewleft,viewright);
|
||||
|
||||
while (iItem) {
|
||||
prevItem=wineItem;
|
||||
wineItem= & infoPtr->items[iItem];
|
||||
wineItem->iLevel=indent;
|
||||
|
||||
ImageList_GetIconSize (infoPtr->himlNormal, &cx, &itemHeight);
|
||||
ImageList_GetIconSize (infoPtr->himlNormal, &x, &itemHeight);
|
||||
if (infoPtr->uItemHeight>itemHeight)
|
||||
itemHeight=infoPtr->uItemHeight;
|
||||
|
||||
|
@ -1112,6 +1103,16 @@ TREEVIEW_Refresh (HWND hwnd, HDC hdc)
|
|||
|
||||
infoPtr->uRealItemHeight=itemHeight;
|
||||
|
||||
iItem=(INT)infoPtr->TopRootItem;
|
||||
infoPtr->firstVisible=0;
|
||||
wineItem=NULL;
|
||||
indent=0;
|
||||
x=y=0;
|
||||
|
||||
while (iItem) {
|
||||
prevItem=wineItem;
|
||||
wineItem= & infoPtr->items[iItem];
|
||||
wineItem->iLevel=indent;
|
||||
|
||||
/* FIXME: remove this in later stage */
|
||||
/*
|
||||
|
@ -1161,7 +1162,6 @@ TREEVIEW_Refresh (HWND hwnd, HDC hdc)
|
|||
while ((!iItem) && (indent>0)) {
|
||||
indent--;
|
||||
x-=infoPtr->uIndent;
|
||||
prevItem=wineItem;
|
||||
wineItem=&infoPtr->items[(INT)wineItem->parent];
|
||||
iItem=(INT)wineItem->sibling;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue