当没设置CBS_NOINTEGRALHEIGHT时,5.0会算一个比较合适的滚动条,而6.0几乎会全展开(一直到屏幕边缘显示不下才有滚动条)。
void ResizeComboBoxHeight(CComboBox &combo, int lines)
{
CRect cbsize; // current size of the combo box
int height; // new height
combo.GetClientRect(&cbsize);
// Compute the new height.
height = combo.GetItemHeight(-1);
height += combo.GetItemHeight(0)*lines;
height += GetSystemMetrics(SM_CYEDGE)*4; // top and botton edges for editbox and dropdown box
combo.SetWindowPos(NULL,0,0,cbsize.right,height,SWP_NOMOVE | SWP_NOZORDER);
}