重写类名为CMyListCtrl,集成CListCtrl
重写OnNotify函数
头文件
private:
virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult);
源文件
BOOL CMyListCtrl::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
//禁止List控件列与列之间的拖拉
switch( ((NMHDR*)lParam)->code )
{
case HDN_BEGINTRACKW://拖动
case HDN_BEGINTRACKA:
case HDN_DIVIDERDBLCLICKA://双击
case HDN_DIVIDERDBLCLICKW:
*pResult = TRUE;
return TRUE;
}
return CListCtrl::OnNotify(wParam, lParam, pResult);
}
在工程中加载
#include "MyListCtrl.h"
CMyListCtrl m_list
这样listctrl控件上的列头就不能因被拖拽、双击而改变了