2011-03-28 22:30:12|?次阅读|上传:wustguangh【已有?条评论】发表评论

关键词:C/C++, MFC, 界面设计|来源:唯设编程网


void CPrintsysDlg::AdjustColumnWidth()
    int nColumnCount = GetColumnCount();

    for (int i = 0; i < nColumnCount; i++)
        m_list.SetColumnWidth(i, LVSCW_AUTOSIZE);
        int nColumnWidth =m_list. GetColumnWidth(i);
        m_list.SetColumnWidth(i, LVSCW_AUTOSIZE_USEHEADER);
        int nHeaderWidth = m_list.GetColumnWidth(i);
        m_list.SetColumnWidth(i, max(nColumnWidth, nHeaderWidth));
    // SetRedraw(TRUE);
int CPrintsysDlg::GetColumnCount()
    CHeaderCtrl* pHeaderCtrl =m_list. GetHeaderCtrl();
    return (pHeaderCtrl->GetItemCount());

As we can see, this function calculates the widths of the Column Headers as well as the Items and sets the width to the larger of the two, so that complete header is visible even if no item is inserted. Also note that the last column will take all the remaining space.


发表评论0条 】