Scolling is messed up in owner drawn Vairable list box

aewarnick

Well-known member
Joined
Jan 29, 2003
Messages
1,031
Scrolling is fine if the owner drawn property is set to fixed but variable messes up scrolling with mouse. Why, and can I fix it?
 
This "phenomina" also occurs when the control was not added by VS but I added it manually with this:

I declare the new instance and set its properties:
this.fileBrowser.Size= this.listBox1.Size;
this.fileBrowser.Location= this.listBox1.Location;
this.fileBrowser.Visible=false;
this.Controls.Add(this.fileBrowser);
Then, later I make it visible.

What I mean by messed up scrolling is it appears to loop all the way around before it scrolls down and looks really bad!!

Has anyone else had this problem and know how to fix it?
Or, can I handle the scrolling myself? I would definately need some help on that though. I wouldnt know where to start.
 
To remove the listbox scrolling animation you need to subclass it
and do two things:

1) Intercept the WM_VSCROLL message and cause cause it to redraw
the listbox (by invalidating it, forcing Windows to paint it).

2) Intercept WM_ERASEBKGND and ignore it; dont allow any processing
to happen.
 
I was looking for the format of coding for intercepting these messages and I found this on the net but I get the following errror:

protected override void WndProc (ref Message message)

No suitible method found to override.

This is the class I am trying to override:
public class FileBrowserLB : ListBox

It compiles when I inherit from UserControl instead of ListBox, Why? Is there a way around it?
 
Last edited by a moderator:
Back
Top