WM_ERASEBKGND - which item?

B

Bob Dankert

I am capturing the WM_ERASEBKGND in my ownerdraw listbox in WndProc to
reduce flicker (if it doesnt erase the background, it doesnt flicker).
However, after the last item in the listbox, there is a spot which should be
filled with white (about half the size of an item) which is instead willed
with half of my last drawn item.

Is there any way to tell in WndProc when WM_ERASEBKGND is called which item
in the listbox it is trying to erase? I want it to not fire on all but the
very end of the listbox.

Thanks,

Bob Dankert
 
B

Bob Dankert

Alright, I figured out an easy workaround for this. In the DrawItem for the
listbox, I just added the code:

if (e.Index == this.Items.Count - 1)

if (this.Bounds.Height - (e.Bounds.Y+e.Bounds.Height) > 0)

e.Graphics.FillRectangle(Brushes.White,e.Bounds.X,e.Bounds.Y+e.Bounds.Height
,e.Bounds.Width,this.Bounds.Height - (e.Bounds.Y+e.Bounds.Height));

This will erase everything within the listbox that is below the last item in
the listbox, and I just cancel all WM_ERASEBKGND events to eliminate all
flicker.



Thanks,

Bob Dankert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top