MFC ClistCtr lock hide a column

      By setting the column width is zero, the list box can be hidden in a column, but the user drags the size of the list box, hidden columns, and may be displayed.

     We can write a CListEx inheritance CListCtr, then drag to capture a message, the message for special treatment.

:: OnNotify CListEx BOOL (WPARAM the wParam, LPARAM the lParam, LRESULT * pResult) 
{ 
    HD_NOTIFY      * PhDN = (HD_NOTIFY * ) the lParam;
     Switch (((the NMHDR *) the lParam) -> code) 
    { 
    Case HDN_BEGINTRACKW: // drag   
    Case HDN_BEGINTRACKA :
          // set do not want to change the column value 
        IF (pHDN-> == iItem m_icolLock) 
        {
             * pResult = TRUE;
             return TRUE; 
        } 
        BREAK ; 
    } 
    return the CListCtrl :: (the wParam, the lParam, pResult) OnNotify; 
}
// set to hide the column 
void CListEx :: LockColoum ( int column) 
{ 
    m_icolLock = column; 
}

Add the header file:

virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult);

 

Guess you like

Origin www.cnblogs.com/ahcc08/p/10987862.html