Click here to Skip to main content
Click here to Skip to main content

Owner-drawn trackbar(slider)

By , 30 Jan 2007
 

Sample Image - ColorSlider.gif

Introduction

This article presents owner-drawn trackbar control. Component is written entirely from scratch. All painting events are done by code. It’s got cool, modern look. The best thing is, however, the capability of changing slider’s thumb shape. It is done simply by providing appropriate graphics path.

Background (optional)

I always wanted to have cool slider for my audio player application. The best I could find here was Guinness4Strength's article. Unfortunately, I didn’t find it pretty enough, so I decided to write my own trackbar. Hopefully you like it.

Properties

Appearance:

  • ThumbSize - Gets or sets the size of the thumb
  • ThumbCustomShape - Gets or sets the thumb custom shape. Use ThumbRect property to determine bounding rectangle.
  • ThumbRoundRectSize - Gets or sets the size of the thumb round rectangle edges.
  • BorderRoundRectSize - Gets or sets the size of the border round rect.

Values:

  • Orientation - Gets or sets the orientation of Slider.
  • Value - Gets or sets the value of Slider.
  • Minimum - Gets or sets the minimum value.
  • Maximum - Gets or sets the maximum value.
  • SmallChange - Gets or sets trackbar's small change. It affects how to behave when directional keys are pressed
  • LargeChange - Gets or sets trackbar's large change. It affects how to behave when PageUp/PageDown keys are pressed

Behavior:

  • DrawFocusRectangle - Gets or sets a value indicating whether to draw focus rectangle.
  • DrawSemitransparentThumb - Gets or sets a value indicating whether to draw semitransparent thumb.
  • MouseEffects - Gets or sets whether mouse entry and exit actions have impact on how control look.
  • MouseWheelBarPartitions - Gets or sets the mouse wheel bar partitions.

Colors:

  • ThumbOuterColor - Gets or sets the thumb outer color.
  • ThumbInnerColor - Gets or sets the inner color of the thumb.
  • ThumbPenColor - Gets or sets the color of the thumb pen.
  • BarOuterColor - Gets or sets the outer color of the bar.
  • BarInnerColor - Gets or sets the inner color of the bar.
  • BarPenColor - Gets or sets the color of the bar pen.
  • ElapsedOuterColor - Gets or sets the outer color of the elapsed.
  • ElapsedInnerColor - Gets or sets the inner color of the elapsed.

Points of Interest

This control will provide design-time support. Next version should contain custom properties editors.

History

  • 30.01.2007 - first version.
  • License

    This article, along with any associated source code and files, is licensed under The GNU Lesser General Public License (LGPLv3)

    About the Author

    Michal Brylka
    Architect Nokia Siemens Networks
    Poland Poland
    Member
    Michał is C# and whole .NET enthusiast. He graduated from computer science MSc studies at Wroclaw University of Technology, Poland.
     
    He is interested in photography and diving. He is member of PADI, currently with divemaster certificate.

    His favorite movies are Matrix, Amélie(Le Fabuleux Destin d'Amélie Poulain), Stargate SG-1 TV Serie and comedies of Mel Brooks.
     
    Michał lives in Wroclaw, Poland. To contact Michał, email him at michal.brylka[mail-'"at'"-sign]op.pl.

    Sign Up to vote   Poor Excellent
    Add a reason or comment to your vote: x
    Votes of 3 or less require a comment

    Comments and Discussions

     
    Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
    You must Sign In to use this message board.
    Search this forum  
        Spacing  Noise  Layout  Per page   
    SuggestionGreat control - some suggestionsmemberdr_thomas1 May '13 - 4:01 
    QuestionthumbCustomShapememberUltiblade11 Mar '13 - 3:54 
    QuestionVertical orientation - reversedmemberthewampek5 Feb '13 - 5:09 
    SuggestionAdding ColorSlider to the VB ToolBoxmemberRavinduL27 Dec '12 - 20:37 
    Questionimage as pen?memberAndres Santillan20 Sep '12 - 18:01 
    GeneralMy vote of 5memberMember 90334004 Jun '12 - 6:04 
    QuestionNice work thanks. My vote is 5memberIssaharNoam11 Jan '12 - 22:18 
    QuestionPanel scrolls on mouse wheel before trackbarmemberhowardfarrar27 Sep '10 - 6:21 
    AnswerRe: Panel scrolls on mouse wheel before trackbarmemberhowardfarrar28 Sep '10 - 1:13 
    GeneralMy vote of 5memberXmen W.K.16 Jul '10 - 15:48 
    Generalgood controlmembersecurigy19 Jun '10 - 0:29 
    GeneralVery cool, small addition I did for myselfmemberIssaharNoam22 Mar '09 - 0:38 
    GeneralRe: Very cool, small addition I did for myselfmemberXmen W.K.16 Jul '10 - 15:50 
    Questionorientation slider value reversedmemberTVW036 Mar '09 - 12:11 
    AnswerRe: orientation slider value reversed [modified]membertgpfarm11027 Mar '09 - 14:30 
    AnswerRe: orientation slider value reversedmemberMichal Brylka8 Mar '09 - 8:57 
    GeneralBrilliant implementation! Following slight change I did for myselfmemberIssaharNoam23 Feb '09 - 0:42 
    GeneralRe: Brilliant implementation! Following slight change I did for myselfmemberMichal Brylka8 Mar '09 - 8:42 
    GeneralFantastic!member-Sean-20 Feb '09 - 11:38 
    GeneralRe: Fantastic!memberMichal Brylka8 Mar '09 - 6:36 
    QuestionConversion to VB?membershalan9918 Oct '07 - 22:59 
    GeneralRe: Conversion to VB?memberMichal Brylka22 Feb '08 - 2:50 
    GeneralSlight improvementsmemberJeromeHordies16 Sep '07 - 5:07 
    GeneralRe: Slight improvementsmemberMichal Brylka14 Feb '08 - 17:43 
    GeneralGreat controlmemberRoss_MacGregor25 Jul '07 - 8:59 
    GeneralMulitple TrackPointsmemberbizzysim6 Jul '07 - 9:36 
    GeneralRe: Mulitple TrackPointsmemberMichal Brylka6 Jul '07 - 10:26 
    NewsGreat Control - added ToolStrip supportmemberThomas-H.28 Jun '07 - 5:08 
    GeneralRe: Great Control - added ToolStrip support [modified]memberMichal Brylka28 Jun '07 - 7:34 
    Generalyour control is very good,I want Two blocks in your control,memberfrequent30 May '07 - 18:55 
    GeneralRe: your control is very good,I want Two blocks in your control,memberMichal Brylka31 May '07 - 8:35 
    QuestionAccessiblity?memberZorbek5 Feb '07 - 21:59 
    AnswerRe: Accessiblity?memberMichal Brylka7 Feb '07 - 1:55 
    GeneralRe: Accessiblity?memberZorbek7 Feb '07 - 13:06 
    GeneralInteresting ideamemberPete O'Hanlon30 Jan '07 - 0:54 
    GeneralRe: Interesting ideamemberMichal Brylka30 Jan '07 - 15:52 
    GeneralAdd few thing to become ultimate ;)memberThe Monz30 Jan '07 - 0:42 
    GeneralRe: Add few thing to become ultimate ;)memberMichal Brylka7 Feb '07 - 2:05 
    GeneralRe: Add few thing to become ultimate ;)memberJ.e.e.P21 Apr '09 - 2:31 

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

    Permalink | Advertise | Privacy | Mobile
    Web02 | 2.6.130516.1 | Last Updated 30 Jan 2007
    Article Copyright 2007 by Michal Brylka
    Everything else Copyright © CodeProject, 1999-2013
    Terms of Use
    Layout: fixed | fluid