Add custom manual will Listcontrl MFC

1. Drag a list control in the toolbox, change the View Report to obtain control property as shown below.

 

 

 2. Right Controls -> Add Variable -> variable of type CListCtrl. Variable names defined according to their own needs. as follows:

 

3. In the message function works added:

DDX_Control (pDX, control ID, variable names);

4. Add the initialization code in the code section controls at initialization or need listcontrl control, safety recommendations list for the first row, first column do not put any element. Make the following code for reference purposes only.

Variable name .SetExtendedStyle (LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES); // entire row select gridlines 
    variable name .InsertColumn ( 0 , _T ( "" ), LVCFMT_CENTER, 0 ); 
    variable name .InsertColumn ( . 1 , _T ( " inspection records " ), LVCFMT_CENTER, m_rectlist_video.Width () / . 8 ); // insert column name column 2

5. Add the following custom function BEGIN_MESSAGE_MAP the list control is further beautification:

ON_NOTIFY(NM_CUSTOMDRAW, 控件ID, OnCustomdrawListerr)

Do not forget to add in the project the corresponding .h file

afx_msg void OnCustomdrawListerr(NMHDR*, LRESULT*);

Then you can rewrite OnCustomdrawListerr function according to their own needs:

void Video :: OnCustomdrawListerr (pNMHDR the NMHDR *, * LRESULT pResult) 
{ 

    NMLVCUSTOMDRAW * = pLVCD reinterpret_cast <NMLVCUSTOMDRAW *> (pNMHDR);
     * pResult = 0 ; 

    // messages should be sent before and after the drawing list item    
    IF (CDDS_PREPAINT pLVCD- ==> nmcd.dwDrawStage) 
    { 
       *********** 
    } 
    the else  IF (CDDS_ITEMPREPAINT pLVCD- ==> nmcd.dwDrawStage) 
    { 
        ******************************************************** 
       ** ****************** 
    } 
}

Due to confidentiality issues not put here the source code, if in doubt or need to code. You can leave a message and exchange ideas.

 

 

个人经验总结,如有错误或者侵犯到您个人的利益,请留言与我联系。

Guess you like

Origin www.cnblogs.com/Guo-xin/p/12030668.html