I have done the ability to fail in a headerctrl, mainly want to keep the HeaderCtrl width unchanged, the method is to overload the virtual function on ListCtrl ONNOTIFY, judge the index ISUBITEM of a column in this function, if it is to invalidate HeaderCtrl settings * IRESULT = true indicates that the message is no longer processed down, and the RETURN, the code is as follows:
BOOL CStyleList :: OnNotify (WPARAM wParam, LPARAM lParam, LRESULT * pResult) {// TODO: Add your specialized code here and / or call the base class NMHEADER * pNMHeader = (NMHEADER *) lParam; if (pNMHeader-> iItem = = 0) {* presult = true; return true;} return clistctrl :: ONNOTIFY (WPARAM, LPARAM, PRESULT);
As a result, all notification messages sent by HeaderCtrl to ListCtrl are not processed, resulting in all functions such as HeaderCtrl, drag and other functions.
Now, I have to make a very simple function: set a bitmap icon on this failerCtrl, because this HeaderCtrl's notification message is all not processed by ListCtrl, set the operation of the bitmap therefore, it is necessary to improve the code. Time:
BOOL CStyleList :: OnNotify (WPARAM wParam, LPARAM lParam, LRESULT * pResult) {// TODO: Add your specialized code here and / or call the base class NMHEADER * pNMHeader = (NMHEADER *) lParam; if (pNMHeader-> iItem = = 0 && ((pNMHeader-> hdr.code == HDN_BEGINTRACKW) | (pNMHeader-> hdr.code == HDN_DIVIDERDBLCLICKW))) {* pResult = TRUE; return TRUE;} return CListCtrl :: (wParam, lParam, pResult OnNotify }
Keep the HeaderCtrl width unchanged, of course, can not pull HeaderCtrl at will. In addition, I noticed that when you double-click between the two headerctrl, it will cause the width of HeaderCtrl, so you need to block these two notification message:
HDN_BEGINTRACKW: When the HEADERCTRL width is started
HDN_DIVIDERDBLCLICKW: When double-click to change the HeaderCtrl width between two headerctr