怎样在代码里实现:双击某一列的表头和下一列的表头交界处使得前一列的宽度自动适配最长得显示元素的功能。
也就是现在我不要用户点那个地方,在其他地方也能实现这个功能。
谢谢!

解决方案 »

  1.   

    方法1,查一查windows message HDN_DIVIDERDBCLICK是怎样实现的
    方法2,遍历该列,用函数CListCtrl::GetStringWidth求每个宽度,取最大值,
          然后CListCtrl::SetColumnWidth()重设宽度就可以了
      

  2.   

    CListCtrl::SetColumnWidth
    This method changes the width of a column in report view or list view.BOOL SetColumnWidth(
    int nCol,
    int cx ); 
    Parameters
    nCol 
    Specifies the index of the column whose width is to be set. In list view, this parameter must be –1. 
    cx 
    Specifies the new width of the column. Can be either LVSCW_AUTOSIZE, LVSCW_AUTOSIZE_USEHEADER or LVM_SETCOLUMNWIDTH.