Again we have to override the OnNotify() function. The
code below restricts the columns to a minimum width of 80 pixels. The logic
can be extended to restrict the width within a range or even specify different
range for different columns. To extend the functionality, you would need
to add member variables to the class to track the different settings.
BOOL CMyListCtrl::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
HD_NOTIFY *pHDN = (HD_NOTIFY*)lParam;
if((pHDN->hdr.code == HDN_ITEMCHANGINGW || pHDN->hdr.code == HDN_ITEMCHANGINGA)
&& pHDN->pitem->cxy < 80)
{
*pResult = TRUE; // disable change
return TRUE; // Processed message
}
return CListCtrl::OnNotify(wParam, lParam, pResult);
}