Jump to content
  • Advertisement
Sign in to follow this  
marshdabeachy

[.net] C# TrackBar stealing focus

This topic is 3757 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

I have an app that does a lot of line drawing, which just draws straight onto the form. This is working fine. However, the assignment called for a trackbar, so I put it on the form. It also works fine. The problem that arises, however, is that the trackbar has stolen focus from the form. Keyboard and scroll wheel functionality that used to work now gets redirected to the trackbar. The only way the trackbar should change is if the user directly clicks on it. Is it possible to disable everything else associated with focus for the trackbar?

Share this post


Link to post
Share on other sites
Advertisement
I'm interested in this as well. I have a paint program that allows you to use the cursor keys to move objects around but after moving the object one pixel the scroll bars grab focus and start scrolling. Really annoying!

Share this post


Link to post
Share on other sites
You should do your drawing to something other than your form, ie. a UserControl, or something derived from Control or Panel. Inside your derived class, override the IsInputKey and/or the IsInputChar methods. If you do something like the below code inside your derived class, then once clicked on the UserControl will receive all keyboard events, and they won't be passed onto other controls in the form.


protected override bool IsInputKey(Keys keyData)
{
return true;
}


Edit: Oh, I don't think this works if you just override IsInputKey in the Form itself. It has to be some other control.

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!