void AdjustCtrlColumns(CListCtrl& lst)
{
CHeaderCtrl*pHead=lst.GetHeaderCtrl();
ASSERT(pHead);
if (pHead)
{
lst.SetRedraw(FALSE);
for (int iCurrCol=0;iCurrCol<pHead->GetItemCount();++iCurrCol)
{
lst.SetColumnWidth(iCurrCol,LVSCW_AUTOSIZE);
int nCurrWith=lst.GetColumnWidth(iCurrCol);
lst.SetColumnWidth(iCurrCol,LVSCW_AUTOSIZE_USEHEADER);
int nColHdrWidth=lst.GetColumnWidth(iCurrCol);
lst.SetColumnWidth(iCurrCol,max(nColHdrWidth,nCurrWith));
}
lst.SetRedraw();
lst.Invalidate();
}
}