Height of CComboBox's drop down list

颜志业
2023-12-01
当Common Control 6.0 和 Common Control 5.0的CComboBox不太一样

当没设置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);
}




 类似资料:

相关阅读

相关文章

相关问答