Painting my own scroll bars

  • Thread starter Thread starter Dragon
  • Start date Start date
D

Dragon

Does anybody know I can override the drawing of scroll bars within a
WinForms app. That's to say, where ever windows (within the app) puts a
scroll bar (H or V), on forms or controls, I need to draw my own scoll bar.

Does anybody know if possible?, and how?, Any examples?
 
I need to paint it my self (need to change it's color for starters)
And, unfortunately, I can't do something like that, or rather it would be
difficult, because I need to control all the scroll bars on the form,
including ones which .NET brings up (e.g. scroll bar in listbox)..

The best guess I've got, is to tap into the message queue and trap the all
the paint events (WM_PAINT), and if they are going to a scroll bar, do
something else.. But that sounds messy.

Roy said:
I created a UserControl, put a scrollbar in it, covered the scroll buttons
with my own buttons, adjusted the width of the scroll bar to suit my "Touch
Screen" needs, anchored the scrollbar & buttons within the UserControl, and
defined / implemented an IScrollable interface. Additionally, I had to set
AutoScroll to false and associate the control I wanted to scroll with my
UserControl-based ScrollBar. Each control then had to implement my
IScrollable interrface.
By using the existing VScrollBar I didn't have to implement the sizing
logic of the bar itself, yet I had some control over the rendering of it.
Perhaps it was not the most elegant way of doing it, but I was new to .Net
and User Interface development.
 
I started by looking at the ScrollableControl class and soon became frustrated by the way the scrollbars were "insulated" by my attempts to customize the look of the scrollbars. Maybe there is some reliance on the Win32 api for some window rendering code... I don't know.

I found it easier to go the UserControl route, wrapping a VScrollBar and a couple of buttons into it, and disabling the AutoScroll property for the ScrollablreControl-derived classes I use. If you are more comfortable with the Win32 API than .Net you may have better luck than I down that path.

Good luck!

-Roy
 
If you have some money to throw at the problem, check out

http://www.SyncFusion.com

They have a nice library of .Net controls, available w/ full source. Their Essential Grid can do anything, including sharing external scrollbars. They derive a ScrollControl from the System.Windows.Forms.Control class where they provide support for shared scrollbars. Their ScrollControl class also provides support for auto-scrolling just like the System.Windows.Forms.ScrollableControl.

I've been a satisfied customer of theirs for two years now. There are lots of classes to learn in the Essential Suite, but the controls are ready-to-use and the support is excellent.

-Roy
 
Back
Top