winapi - Minimum width of a list control without horizontal scrollbar -
i have list control in report mode.
i fill list control data , auto size columns lvm_setcolumnwidth
. depending on data list control may end horizontal scrollbar or not.
so far good. i'd minimum width list control should have no horizontal scrollbar needed. knowing size resize list control in order rid of horizontal scrollbar.
any ideas ?
since know required width, can use information , have system calculate corresponding window width you. either of following apis can used: adjustwindowrect or adjustwindowrectex. height can ignored.
int requiredwidth = 0; ( int index = 0; index < itemcount; ++index ) { // calculate item width requiredwidth += itemwidth; } rect r = { 0, 0, requiredwidth, 1 }; dword style = (dword)::getwindowlongptr( hlist, gwl_style ); dword styleex = (dword)::getwindowlongptr( hlist, gwl_exstyle ); ::adjustwindowrectex( &r, style, false, styleex ); int windowwidth = r.right - r.left;
Comments
Post a Comment