How to set a minimum column width
Posted
by Zafir Anjum
on August 6th, 1998
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);
}

Comments
Fix when dragging fast
Posted by Legacy on 11/30/1998 12:00amOriginally posted by: Cees Mechielsen
ReplyColumn resizing when "Show window contents while dragging" is not checked
Posted by Legacy on 11/27/1998 12:00amOriginally posted by: Grant Gussie
ReplyFix for column headers
Posted by Legacy on 11/21/1998 12:00amOriginally posted by: Michael Easter
ReplySlight modification for owner-drawn column headers
Posted by Legacy on 10/28/1998 12:00amOriginally posted by: Chip Calvert
Reply