正文

Custom Draw ListView Controls(7)2009-01-20 12:00:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/yuqiexing/40624.html

分享到:

 // do we want to do any drawing after

 // the list control is finished

 virtual bool IsSubItemPostDraw() { return false; }

 // if we are doing the drawing afterwards ourselves

 // override and put the code in here

 // the return value is not used here

 virtual bool OnSubItemPostDraw(CDC* /*pDC*/,

                                int /*nItem*/,

                                int /*nSubItem*/,

                                UINT /*nState*/,

                                LPARAM /*lParam*/)

 { return false; }


There is quite a bit of code here as well. Again, there is good new. Each of the virtual functions performs a simple and well-defined task. The OnCustomdraw function does all the housework and ties everything together.

Well, that about wraps it up for our CListCtrlWithCustomDraw class. The last step is to derive a class from CListCtrlWithCustomDraw.

 

Using the CListCtrlWithCustomDraw Class

Again, we can use the WizardBar to create a new class. And as before it can be done with a little hacking. Start off by defining a class call CMyListCtrl, and say that it is an MFC class derived from CListCtrl. Then edit the .h and .cpp files that are generated, change all occurrences of CListCtrl to CListCtrlWithCustomDraw, and finally add a #include "ListCtrlWithCustomDraw.h" line to the .h file, just before the class declaration. Once you have the skeleton CMyListCtrl, we can override some of the virtual functions to change the appearance of the control.

 

 

 

 

阅读(1620) | 评论(2)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

loading...
您需要登录后才能评论,请 登录 或者 注册