Jump to content
  • Advertisement
Sign in to follow this  
ArchangelMorph

[.net] C# Trackbar Control

This topic is 3737 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So I've got a trackbar slider in my XNA/winforms editor for use with my custom animation editor suite.. The issue I have is I would like to draw markers/icons on to the trackbar to specify where along the timeline keyframes have been set & also draw text underneath the ticks to specify the time intervals.. I haven't done any custom controls with WinForms before & so I was wondering how I would go about creating a custom trackbar which will allow me to add these specific features to the control..? Any help would be much appreciated! Thanks!

Share this post


Link to post
Share on other sites
Advertisement
The easiest way would probably be to create a subclass of TrackBar and override the OnPaint method. By calling base.OnPaint first and then drawing your custom stuff over it, you can take advantage of the basic TrackBar functionality so you only have to add code for your specialized features.

Hope this helps :)

Share this post


Link to post
Share on other sites
Thanks for the info..

Any idea how i'd handle doing the drawing of the other assets ontop of the control..?

Is there something like wxWidgets' wxClientDC in WinForms (C#)...?

Share this post


Link to post
Share on other sites

Well, if you want to render complete WinForms controls on top of the TrackBar, you're probably better off using a container (like a Panel) and arranging your controls over eachother as you want. This should allow you to have the panel take care of the focus stuff and the troubles of handling user input.

Overriding OnPaint like I suggested is mainly useful if you want to extend the functionality of a given control, like adding tick labels and drawing special keyframe ticks. You can use the Graphics object suppied in the PaintEventArgs to draw all kinds of shapes based on the data you have. It is a bit lowlevel, so it can take some extra work to deal with the layout and drawing complexer things, but rereading your post I think this would still be the way to go.

I don't know wxWidgets, but I took a quick look on Google and it seems similar to what the Graphics object allows you to do in .NET. I may be way of here though [smile]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!