Modified CBDropDown to find the best height of the listbox.

This commit is contained in:
Pierre Mageau 1999-09-05 12:12:30 +00:00 committed by Alexandre Julliard
parent 3b96efc0f7
commit a433582363
1 changed files with 10 additions and 5 deletions

View File

@ -1112,7 +1112,7 @@ static void CBDropDown( LPHEADCOMBO lphc )
int nItems = 0; int nItems = 0;
int i; int i;
int nHeight; int nHeight;
int nDroppedHeight; int nDroppedHeight, nTempDroppedHeight;
TRACE("[%04x]: drop down\n", CB_HWND(lphc)); TRACE("[%04x]: drop down\n", CB_HWND(lphc));
@ -1152,19 +1152,24 @@ static void CBDropDown( LPHEADCOMBO lphc )
items list, then force the drop down list height to be the total height items list, then force the drop down list height to be the total height
of the items in the dropped list */ of the items in the dropped list */
/* And Remove any extra space (Best Fit) */
nDroppedHeight = lphc->droppedRect.bottom - lphc->droppedRect.top; nDroppedHeight = lphc->droppedRect.bottom - lphc->droppedRect.top;
nItems = (int)SendMessageA (lphc->hWndLBox, LB_GETCOUNT, 0, 0); nItems = (int)SendMessageA (lphc->hWndLBox, LB_GETCOUNT, 0, 0);
nHeight = COMBO_YBORDERGAP; nHeight = COMBO_YBORDERSIZE();
nTempDroppedHeight = 0;
for (i = 0; i < nItems; i++) for (i = 0; i < nItems; i++)
{ {
nHeight += (int)SendMessageA (lphc->hWndLBox, LB_GETITEMHEIGHT, i, 0); nHeight += (int)SendMessageA (lphc->hWndLBox, LB_GETITEMHEIGHT, i, 0);
if (nHeight >= nDroppedHeight) /* Did we pass the limit of what can be displayed */
if (nHeight > nDroppedHeight)
{
break; break;
} }
nTempDroppedHeight = nHeight;
}
if (nHeight < nDroppedHeight) nDroppedHeight = nTempDroppedHeight;
nDroppedHeight = nHeight;
SetWindowPos( lphc->hWndLBox, HWND_TOP, rect.left, rect.bottom, SetWindowPos( lphc->hWndLBox, HWND_TOP, rect.left, rect.bottom,
lphc->droppedRect.right - lphc->droppedRect.left, lphc->droppedRect.right - lphc->droppedRect.left,