comctl32/treeview: Prevent item height to be calculated to zero value.
This commit is contained in:
parent
03bd3c8040
commit
66bad889f4
|
@ -713,6 +713,32 @@ static void test_get_set_itemheight(void)
|
|||
ok_sequence(sequences, TREEVIEW_SEQ_INDEX, test_get_set_itemheight_seq,
|
||||
"test get set item height", FALSE);
|
||||
|
||||
/* without TVS_NONEVENHEIGHT */
|
||||
SetWindowLong(hTree, GWL_STYLE, GetWindowLong(hTree, GWL_STYLE) & ~TVS_NONEVENHEIGHT);
|
||||
/* odd value */
|
||||
ulOldHeight = SendMessage( hTree, TVM_SETITEMHEIGHT, 3, 0);
|
||||
ok(ulOldHeight == 8, "got %d, expected %d\n", ulOldHeight, 8);
|
||||
ulNewHeight = (int) SendMessage( hTree, TVM_GETITEMHEIGHT, 0, 0 );
|
||||
ok(ulNewHeight == 2, "got %d, expected %d\n", ulNewHeight, 2);
|
||||
|
||||
ulOldHeight = SendMessage( hTree, TVM_SETITEMHEIGHT, 4, 0);
|
||||
ok(ulOldHeight == 2, "got %d, expected %d\n", ulOldHeight, 2);
|
||||
ulNewHeight = (int) SendMessage( hTree, TVM_GETITEMHEIGHT, 0, 0 );
|
||||
ok(ulNewHeight == 4, "got %d, expected %d\n", ulNewHeight, 4);
|
||||
|
||||
/* with TVS_NONEVENHEIGHT */
|
||||
SetWindowLong(hTree, GWL_STYLE, GetWindowLong(hTree, GWL_STYLE) | TVS_NONEVENHEIGHT);
|
||||
/* odd value */
|
||||
ulOldHeight = SendMessage( hTree, TVM_SETITEMHEIGHT, 3, 0);
|
||||
ok(ulOldHeight == 4, "got %d, expected %d\n", ulOldHeight, 4);
|
||||
ulNewHeight = (int) SendMessage( hTree, TVM_GETITEMHEIGHT, 0, 0 );
|
||||
ok(ulNewHeight == 3, "got %d, expected %d\n", ulNewHeight, 3);
|
||||
/* even value */
|
||||
ulOldHeight = SendMessage( hTree, TVM_SETITEMHEIGHT, 10, 0);
|
||||
ok(ulOldHeight == 3, "got %d, expected %d\n", ulOldHeight, 3);
|
||||
ulNewHeight = (int) SendMessage( hTree, TVM_GETITEMHEIGHT, 0, 0 );
|
||||
ok(ulNewHeight == 10, "got %d, expected %d\n", ulNewHeight, 10);
|
||||
|
||||
DestroyWindow(hTree);
|
||||
}
|
||||
|
||||
|
|
|
@ -1828,7 +1828,7 @@ TREEVIEW_SetItemHeight(TREEVIEW_INFO *infoPtr, INT newHeight)
|
|||
{
|
||||
INT prevHeight = infoPtr->uItemHeight;
|
||||
|
||||
TRACE("%d\n", newHeight);
|
||||
TRACE("new=%d, old=%d\n", newHeight, prevHeight);
|
||||
if (newHeight == -1)
|
||||
{
|
||||
infoPtr->uItemHeight = TREEVIEW_NaturalHeight(infoPtr);
|
||||
|
@ -1836,13 +1836,17 @@ TREEVIEW_SetItemHeight(TREEVIEW_INFO *infoPtr, INT newHeight)
|
|||
}
|
||||
else
|
||||
{
|
||||
infoPtr->uItemHeight = newHeight;
|
||||
infoPtr->bHeightSet = TRUE;
|
||||
if (newHeight == 0) newHeight = 1;
|
||||
infoPtr->uItemHeight = newHeight;
|
||||
infoPtr->bHeightSet = TRUE;
|
||||
}
|
||||
|
||||
/* Round down, unless we support odd ("non even") heights. */
|
||||
if (!(infoPtr->dwStyle & TVS_NONEVENHEIGHT))
|
||||
infoPtr->uItemHeight &= ~1;
|
||||
if (!(infoPtr->dwStyle & TVS_NONEVENHEIGHT) && infoPtr->uItemHeight != 1)
|
||||
{
|
||||
infoPtr->uItemHeight &= ~1;
|
||||
TRACE("after rounding=%d\n", infoPtr->uItemHeight);
|
||||
}
|
||||
|
||||
if (infoPtr->uItemHeight != prevHeight)
|
||||
{
|
||||
|
@ -2062,6 +2066,7 @@ static inline LRESULT
|
|||
TREEVIEW_GetVisibleCount(const TREEVIEW_INFO *infoPtr)
|
||||
{
|
||||
/* Surprise! This does not take integral height into account. */
|
||||
TRACE("client=%d, item=%d\n", infoPtr->clientHeight, infoPtr->uItemHeight);
|
||||
return infoPtr->clientHeight / infoPtr->uItemHeight;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue