call DrawItem(). OnPaint()
I have a class named CMyListCtrl derived from CListCtrl using LVS_REPORT
with multiple columns. It is owner draw and overrides both OnPaint() and
DrawItem().but it dosen't work,only onpaint() function work,and the drawitem can't be called .why the drawitem and onpaint function aren't carried out at the same time and just execute onpaint?thank you to help me.
Re: call DrawItem(). OnPaint()
Quote:
Originally Posted by
xiaohangge
... it dosen't work,only onpaint() function work,and the drawitem can't be called .why?
why? :confused:
Because you did something wrong! :rolleyes:
Re: call DrawItem(). OnPaint()
Quote:
Originally Posted by
VictorN
why? :confused:
Because you did something wrong! :rolleyes:
I set a breakpoint in drawitem,but there are nothing reaction.
Re: call DrawItem(). OnPaint()
Quote:
Originally Posted by
xiaohangge
I set a breakpoint in drawitem,but there are nothing reaction.
We had already understood it after reading your OP. :cool:
Re: call DrawItem(). OnPaint()
Quote:
Originally Posted by
VictorN
We had already understood it after reading your OP. :cool:
do you have some answers?
Re: call DrawItem(). OnPaint()
Well, you asked only one question. It was: "why?"
And I already answered you in the post#2.
However, if you want more help then you have to provide more useful info about your project, class, control, implementation, and so on... Maybe posting a small test project reproducing your problem would be useful...
Re: call DrawItem(). OnPaint()
.if i do not define onpaint,drawitem can be called.i refer to some information,and some say if the ower window has the onpaint fuction,the overrided drawitem would not be called.i do not know whether it is correct,and if it is correct,why is it so?
Re: call DrawItem(). OnPaint()
xiaohangge,
I did a few Google searches and found an old CodeGuru forum question asking something similar (this is not a "why didn't you look this up first" post, I found it by accident).
http://www.codeguru.com/forum/archiv.../t-327604.html
But a big part of your problem may be that OnDraw() is called within OnPaint() and because you are not calling either the original OnPaint() or not just not calling OnDraw() within your override method.
If you are completely controlling the OnPaint then call your ONDraw() but it would be wise to call the original OnPaint() within your method and let it call your OnDraw(). Whenever we override MFC methods we tend to call into the original either first or at the end just so the system handles most of the work and we can just do what we wanted...
Re: call DrawItem(). OnPaint()
If you mean that you implemented the OnPaint in your CMyListCtrl class then I should say that you don't need it at all.
What you need to (and must if you are using owner draw list control) is override the virtual CListCtrl::DrawItem in this CMyListCtrl class!
Re: call DrawItem(). OnPaint()
Quote:
Originally Posted by
DemonPiggies
xiaohangge,
I did a few Google searches and found an old CodeGuru forum question asking something similar (this is not a "why didn't you look this up first" post, I found it by accident).
http://www.codeguru.com/forum/archiv.../t-327604.html
But a big part of your problem may be that OnDraw() is called within OnPaint() and because you are not calling either the original OnPaint() or not just not calling OnDraw() within your override method.
If you are completely controlling the OnPaint then call your ONDraw() but it would be wise to call the original OnPaint() within your method and let it call your OnDraw(). Whenever we override MFC methods we tend to call into the original either first or at the end just so the system handles most of the work and we can just do what we wanted...
Thanks,but what i said is about drawitem and onpaint in clistctrl class,not ondraw and onpaint.
Re: call DrawItem(). OnPaint()
Quote:
Originally Posted by
VictorN
If you mean that you implemented the OnPaint in your CMyListCtrl class then I should say that you don't need it at all.
What you need to (and must if you are using owner draw list control) is override the virtual CListCtrl::DrawItem in this CMyListCtrl class!
thank you. Can you give me elaborate explanations which work is done in both functions-drawitem and onpaint -respectively.if I want to use both functions at the same time ,how to implment,
Re: call DrawItem(). OnPaint()