473,651 Members | 2,742 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How program function keys (e.g. F1, F2) in Windows app?

I'm writing a Windows app and want to associate function keys with some of
my menu items (e.g. Help (F1)) and buttons. How can I do this, please?

Thanks.
Mar 23 '06 #1
7 4157

Ronald S. Cook wrote:
I'm writing a Windows app and want to associate function keys with some of
my menu items (e.g. Help (F1)) and buttons. How can I do this, please?

Thanks.


For menu items - you simply set it's shortcut propertie to the function
key you want it to use...

--
Tom Shelton [MVP]

Mar 23 '06 #2
"Ronald S. Cook" <rc***@westinis .com> schrieb:
I'm writing a Windows app and want to associate function keys with some of
my menu items (e.g. Help (F1)) and buttons.


Menu items have a 'Shortcut' property which can be used to assign keyboard
shortcuts to them. Buttons support shortcuts by embedding an ampersand
character in their 'Text' property value, such as "&Save", which will make
Alt+S raise the button's 'Click' event.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Mar 23 '06 #3
"Ronald S. Cook" <rc***@westinis .com> schrieb
I'm writing a Windows app and want to associate function keys with
some of my menu items (e.g. Help (F1)) and buttons. How can I do
this, please?

Set the Shortcuts property for menus. Handle the KeyDown event at form level
(KeyPreview = True) to handle them without a menu.
Armin

Mar 24 '06 #4
So how can I assign a function key (e.g. F3) to a button?

Thanks.

"Armin Zingler" <az*******@free net.de> wrote in message
news:OT******** ******@TK2MSFTN GP10.phx.gbl...
"Ronald S. Cook" <rc***@westinis .com> schrieb
I'm writing a Windows app and want to associate function keys with
some of my menu items (e.g. Help (F1)) and buttons. How can I do
this, please?

Set the Shortcuts property for menus. Handle the KeyDown event at form
level (KeyPreview = True) to handle them without a menu.
Armin

Mar 24 '06 #5
"Ronald S. Cook" <rc***@westinis .com> schrieb
So how can I assign a function key (e.g. F3) to a button?


You can not assign a function key to a button. You can handle the key at
Form level and call the same procedure that is called when the button is
clicked.
see also:

http://support.microsoft.com/default...b;en-us;839201
http://msdn.microsoft.com/library/en...teractions.asp

Armin

Mar 25 '06 #6
You can also use mybutton.perfor mclick.
--
Dennis in Houston
"Armin Zingler" wrote:
"Ronald S. Cook" <rc***@westinis .com> schrieb
So how can I assign a function key (e.g. F3) to a button?


You can not assign a function key to a button. You can handle the key at
Form level and call the same procedure that is called when the button is
clicked.
see also:

http://support.microsoft.com/default...b;en-us;839201
http://msdn.microsoft.com/library/en...teractions.asp

Armin

Mar 26 '06 #7
"Dennis" <De****@discuss ions.microsoft. com> schrieb
You can also use mybutton.perfor mclick.

Yes, you can, but I never suggest it because no button has been clicked.
Armin
Mar 27 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2781
by: Tommo | last post by:
Hello All, I am a still learning so be easy on me. I am trying to get some code to work that is using JS and Perl/CGI, I am using AS Perl and an Apache Server on XP as the webserver. Can anyone take a look at the code and tell me why I am getting Apache Server errors in the code below (Part A), when I modify the code as shown in part B the errors go but the JS does not run ?? Part A.
4
17464
by: Sean Connery | last post by:
Does someone know the syntax to detect when certain function keys are pressed?
0
2025
by: federico | last post by:
Hello, how can I make a program respond to another program's input request? For example, this code: Process.Start("unrar.exe", "e D:\temp\key.rar D:temp2") SendKeys.SendWait("test~") will successfully start a program that prompts for a password, and then submit the password via SendKeys. SendKeys will work with both console and windows prompts. However, the program only works when is executed by
8
17750
by: Alvin | last post by:
Right. I`m using Dev-Cpp, and I`m working on a game at this time in SDL (http://libsdl.org), and I`ve come across this error: ------------------------------------------ main.c: In function `SDL_main': main.c:140: error: stray '\160' in program main.c:140: error: stray '\160' in program main.c:140: error: stray '\160' in program main.c:140: error: stray '\160' in program
23
2371
by: JoeC | last post by:
I am a self taught programmer and I have figured out most syntax but desigining my programs is a challenge. I realize that there are many ways to design a program but what are some good rules to follow for creating a program? I am writing a map game program. I created several objects: board object that is an array of integers each number 0-5 is a kind of terrain, a terrain object that is an array of terrain types and each number of...
1
10139
by: Martijn Mulder | last post by:
/* I have problems detecting the Arrow Keys on a User Control. A control derived from System.Windows.Forms.Control neglects 'bare' Arrow Keys but does react on the combination <Altor <Ctrl+ Arrow Key. The code below shows what I mean. How can I cure this? (excuse me for the line breaks) */
4
8002
by: Mo | last post by:
Hi, I am writing a console application to send a key sequence to an old clunky application on a regular interval using the windows scheduler. I can get it to work if it is a windows form application but not in a console application. Two questions I have: 1) how can I get this code modified to use System.Windows.Forms.Keys 2) I like to pass a parameter to the console app to indicate which key needs to be passed to the application. so:
2
1651
by: mindscreen | last post by:
I want to use Right-Click menu of mouse in any form or anywhere in my program? How can I able to do this? I want that when user right-click on any button or form a special pop-up menu will appear with some extra options, whenever user click any option, it will work. I also want to use the Function Keys in my program. Such as, whenever any user press F1, a new form will appear that describe about the software and help topics. For Function...
0
8357
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8277
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8700
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8581
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7298
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6158
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4285
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2701
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1910
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.