在CListCtrl派生类中加入:
BOOL CMyList::OnNotify(WPARAM wParam,LPARAM lParam,LRESULT* pResult)
{
if((pHDN->hdr.code==HDN_BEGINTRACKW||pHDN->hdr.code==HDN_BEGINTRACKA)&&((pHDN->iItem==2)||(pHDN->iItem==3)))
{
*pResult=TRUE;
return TRUE;
}
return CListCtrl::OnNotify(wParam,lParam,*pResult);
}
以上代码禁止改变2、3列宽度;
BOOL CMyList::OnNotify(WPARAM wParam,LPARAM lParam,LRESULT* pResult)
{
if((pHDN->hdr.code==HDN_BEGINTRACKW||pHDN->hdr.code==HDN_BEGINTRACKA)&&((pHDN->iItem==2)||(pHDN->iItem==3)))
{
*pResult=TRUE;
return TRUE;
}
return CListCtrl::OnNotify(wParam,lParam,*pResult);
}
以上代码禁止改变2、3列宽度;
在该消息处理函数内判断列宽是否改变