|
-
September 21st, 2011, 05:06 AM
#1
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.
Last edited by xiaohangge; September 21st, 2011 at 09:05 AM.
-
September 21st, 2011, 05:37 AM
#2
-
September 21st, 2011, 06:11 AM
#3
Re: call DrawItem(). OnPaint()
 Originally Posted by VictorN
why? 
Because you did something wrong! 
I set a breakpoint in drawitem,but there are nothing reaction.
-
September 21st, 2011, 06:17 AM
#4
Re: call DrawItem(). OnPaint()
 Originally Posted by xiaohangge
I set a breakpoint in drawitem,but there are nothing reaction.
We had already understood it after reading your OP.
Victor Nijegorodov
-
September 21st, 2011, 06:30 AM
#5
Re: call DrawItem(). OnPaint()
 Originally Posted by VictorN
We had already understood it after reading your OP. 
do you have some answers?
-
September 21st, 2011, 06:34 AM
#6
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...
Victor Nijegorodov
-
September 21st, 2011, 10:02 AM
#7
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?
-
September 21st, 2011, 10:29 AM
#8
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...
-
September 21st, 2011, 10:33 AM
#9
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: rawItem in this CMyListCtrl class!
Victor Nijegorodov
-
September 21st, 2011, 08:48 PM
#10
Re: call DrawItem(). OnPaint()
 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.
-
September 21st, 2011, 09:00 PM
#11
Re: call DrawItem(). OnPaint()
 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:  rawItem 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,
-
September 22nd, 2011, 01:14 AM
#12
Re: call DrawItem(). OnPaint()
Victor Nijegorodov
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|