BOOL CMyListCtrl::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
HD_NOTIFY *pHDNotify = (HD_NOTIFY*)lParam;
if( pHDNotify->iItem == 需要限制大小的列 )
{
switch( pHDNotify->hdr.code )
{
// How to force a minimum column width Cees Mechielsen.
// http://www.codeguru.com/mfc/comments/866.shtml
case HDN_ITEMCHANGINGA:
case HDN_ITEMCHANGINGW:
case HDN_ENDTRACK:
{
if( pHDNotify->pitem->mask & HDI_WIDTH &&
pHDNotify->pitem->cxy < m_nMinSize &&
pHDNotify->pitem->cxy >= 0 )
{
pHDNotify->pitem->cxy = m_nMinSize; // Set the column width
}
}
break;
// Prevent CListCtrl column resizing
case HDN_DIVIDERDBLCLICKA:
case HDN_DIVIDERDBLCLICKW:
case HDN_BEGINTRACKW:
case HDN_BEGINTRACKA:
{
*pResult = TRUE; // disable tracking
return TRUE;
}
}
}
return CListCtrl::OnNotify(wParam, lParam, pResult);
}
{
HD_NOTIFY *pHDNotify = (HD_NOTIFY*)lParam;
if( pHDNotify->iItem == 需要限制大小的列 )
{
switch( pHDNotify->hdr.code )
{
// How to force a minimum column width Cees Mechielsen.
// http://www.codeguru.com/mfc/comments/866.shtml
case HDN_ITEMCHANGINGA:
case HDN_ITEMCHANGINGW:
case HDN_ENDTRACK:
{
if( pHDNotify->pitem->mask & HDI_WIDTH &&
pHDNotify->pitem->cxy < m_nMinSize &&
pHDNotify->pitem->cxy >= 0 )
{
pHDNotify->pitem->cxy = m_nMinSize; // Set the column width
}
}
break;
// Prevent CListCtrl column resizing
case HDN_DIVIDERDBLCLICKA:
case HDN_DIVIDERDBLCLICKW:
case HDN_BEGINTRACKW:
case HDN_BEGINTRACKA:
{
*pResult = TRUE; // disable tracking
return TRUE;
}
}
}
return CListCtrl::OnNotify(wParam, lParam, pResult);
}