Solved

Keyboard Shortcuts, Windows, Alt Key

Posted on 2016-08-11
4
39 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
  • 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now