Solved

Keyboard Shortcuts, Windows, Alt Key

Posted on 2016-08-11
4
53 Views
Last Modified: 2016-08-15
I have an Windows app for which I want the keyboard shortcuts to be shown.  By this I mean the underscore.  I understand that the user has to hit the alt key to show them, and that this was a Windows behavior change at some point.   How can I show them by default just within my app?
0
Comment
Question by:HLRosenberger
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 20

Expert Comment

by:Russ Suter
ID: 41752478
This is done system-wide using the accessibility options in the Control Panel. If you wish to override this default behavior you'll probably need to subclass the Button control and override the OnPaint event. This means you need to handle painting the rectangle as well as the text. To fully implement this properly you'll need to deal with painting during hover and click actions as well. It's not impossible but it's a bit of a task.
0
 
LVL 1

Author Comment

by:HLRosenberger
ID: 41752538
that's too much work.  I thought maybe there was an easy way.  What about send the ALT key to my app?
0
 
LVL 20

Accepted Solution

by:
Russ Suter earned 500 total points
ID: 41752583
OK, interesting idea. Yes, you should be able to do this. I experimented with it a little. You can't actually do it on the Form_Load event handler since the form hasn't fully rendered yet. The quick and dirty way to do it is to add a Timer control to the form, set its properties as follows:
(Name): [whatever you want]
Enabled: True
GenerateMember: True
Interval: 1
Modifiers: Private
Tag:
Then add a Tick event handler and put this code in there:
        private void timer1_Tick(object sender, EventArgs e)
        {
            SendKeys.SendWait("%{UP}");
            timer1.Enabled = false;
        }

Open in new window

Voila! You've sent an ALT+UP keystroke to your form. I'm still looking into how to send just an ALT key by itself but that doesn't seem to be an option. ALT+UP is somewhat innocuous and shouldn't cause any adverse side-effects unless your form is specifically looking for that keystroke.
0
 
LVL 1

Author Closing Comment

by:HLRosenberger
ID: 41756241
thanks
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question