Overriding OnPaint of CListView 
Author Message
 Overriding OnPaint of CListView

Hi.

I have created a ListView where its ListCtrl contains 6000 elements. I
am now in a position where I have to do an action everytime the ListCtrl
is redrawn in my view. That is whenever I insert a new element into the
ListCtrl, or whenever I scroll, or whenever I reopen my ListView, I have
to update part of the data that is viewed. And this action has to be
done after drawing the elements.
I thought this was a simple case: Simply override OnPaint of ListView
and have it do what it normally does by calling CListView::OnPaint() and
after that call, I perform the action mentioned above. The problem here
is that a call to CListView::OnPaint() does not do anything. How could I
go about solving my problem?
Another solution would be that I implement the normal OnPaint() of the
CListView, that is make it draw my ListCtrl in the View, and then
perform the action. But how do I draw the exact same ListCtrl as the
normal CListView::OnPaint() does it.

I hope you understood what I am asking about.

Thank you very much in advance
Jihad Haddad



Sat, 11 Dec 2004 14:58:09 GMT  
 Overriding OnPaint of CListView
Try to override CView::OnDraw instead...

Ivan


Quote:
> Hi.

> I have created a ListView where its ListCtrl contains 6000 elements. I
> am now in a position where I have to do an action everytime the ListCtrl
> is redrawn in my view. That is whenever I insert a new element into the
> ListCtrl, or whenever I scroll, or whenever I reopen my ListView, I have
> to update part of the data that is viewed. And this action has to be
> done after drawing the elements.
> I thought this was a simple case: Simply override OnPaint of ListView
> and have it do what it normally does by calling CListView::OnPaint() and
> after that call, I perform the action mentioned above. The problem here
> is that a call to CListView::OnPaint() does not do anything. How could I
> go about solving my problem?
> Another solution would be that I implement the normal OnPaint() of the
> CListView, that is make it draw my ListCtrl in the View, and then
> perform the action. But how do I draw the exact same ListCtrl as the
> normal CListView::OnPaint() does it.

> I hope you understood what I am asking about.

> Thank you very much in advance
> Jihad Haddad



Sat, 11 Dec 2004 18:00:17 GMT  
 Overriding OnPaint of CListView
I tried, but it is not called at all. I believe it is the OnPaint that
is called. Normally when I use the Visual Studios wizard to override a
virtual function or implement a handler to some message, the wizard adds
a call to the same function but of the baseclass. This is not done here.
I wonder why

Thanks anyways

Jihad Haddad


Quote:
> Try to override CView::OnDraw instead...

> Ivan



> > Hi.

> > I have created a ListView where its ListCtrl contains 6000 elements.
I
> > am now in a position where I have to do an action everytime the
ListCtrl
> > is redrawn in my view. That is whenever I insert a new element into
the
> > ListCtrl, or whenever I scroll, or whenever I reopen my ListView, I
have
> > to update part of the data that is viewed. And this action has to be
> > done after drawing the elements.
> > I thought this was a simple case: Simply override OnPaint of
ListView
> > and have it do what it normally does by calling CListView::OnPaint()
and
> > after that call, I perform the action mentioned above. The problem
here
> > is that a call to CListView::OnPaint() does not do anything. How
could I
> > go about solving my problem?
> > Another solution would be that I implement the normal OnPaint() of
the
> > CListView, that is make it draw my ListCtrl in the View, and then
> > perform the action. But how do I draw the exact same ListCtrl as the
> > normal CListView::OnPaint() does it.

> > I hope you understood what I am asking about.

> > Thank you very much in advance
> > Jihad Haddad



Sun, 12 Dec 2004 08:19:43 GMT  
 Overriding OnPaint of CListView
    I see, I think it's because MFC creates only a thin wrapper around
common controls and does not give the full functionality as with "normal"
views. You can try to set ownerdraw attribute of a listview and override
DrawItem member function. But then you have to draw all yourself. BTW do you
think it is a good idea to connect the action to WM_PAINT? Anyway, have a
look at CListCtrl. There you can specify callbacks that are called before
the text is painted and you also have a lot of notifications that can be
useful for you...

Ivan


Quote:
> I tried, but it is not called at all. I believe it is the OnPaint that
> is called. Normally when I use the Visual Studios wizard to override a
> virtual function or implement a handler to some message, the wizard adds
> a call to the same function but of the baseclass. This is not done here.
> I wonder why

> Thanks anyways

> Jihad Haddad



> > Try to override CView::OnDraw instead...

> > Ivan



> > > Hi.

> > > I have created a ListView where its ListCtrl contains 6000 elements.
> I
> > > am now in a position where I have to do an action everytime the
> ListCtrl
> > > is redrawn in my view. That is whenever I insert a new element into
> the
> > > ListCtrl, or whenever I scroll, or whenever I reopen my ListView, I
> have
> > > to update part of the data that is viewed. And this action has to be
> > > done after drawing the elements.
> > > I thought this was a simple case: Simply override OnPaint of
> ListView
> > > and have it do what it normally does by calling CListView::OnPaint()
> and
> > > after that call, I perform the action mentioned above. The problem
> here
> > > is that a call to CListView::OnPaint() does not do anything. How
> could I
> > > go about solving my problem?
> > > Another solution would be that I implement the normal OnPaint() of
> the
> > > CListView, that is make it draw my ListCtrl in the View, and then
> > > perform the action. But how do I draw the exact same ListCtrl as the
> > > normal CListView::OnPaint() does it.

> > > I hope you understood what I am asking about.

> > > Thank you very much in advance
> > > Jihad Haddad



Sun, 12 Dec 2004 10:50:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. CListView - Overriding OnPaint()

2. About override the OnPaint function.

3. About override the OnPaint function!

4. Override OnPaint in ATL/WTL

5. OnPaint override on CListViewCtrl?

6. OnPaint() override

7. Can we override a control's OnPaint ?

8. CListBox -- Owner Drawn - (override OnPaint) - Need help, please!

9. Overriding the OnPaint method for button controls

10. overriding events (OnPaint, OnClick, etc.)

11. CListCtrl - override clistctrl in clistview

12. Q: How to override CListView drawing?

 

 
Powered by phpBB® Forum Software