Sometime you use CListView and need to extend the functionality of the CListCtrl of the view. For example, you want to overwrite the handler function of the NM_CUSTOMDRAW or WM_SIZE message. So the problem is: How to tell CListView to use your own CListCtrl?

OK, you are on the wrong way now.

The CListView does not use or contain the MFC CListCtrl, it only wraps a subclassed SysListView32 control as a CCtrlView, in the other hand, the view is the control.

If all you’ve done in your custom CListCtrl derived class is to handle the reflected NM_CUSTOMDRAW message, your best bet to get this working as a custom CListView is to derive a class from CListView and handle the reflected message for it just as you do in your CListCtrl derived implementation.

If you want get  more custom control or you have already make an extended version of CList, It may be easier to derive a view class from CView and use your own CListCtrl in the view.

There are two articles about this topic on CodeGuru:

Tags: , , ,