Home All Groups Group Topic Archive Search About

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

Author
23 Mar 2006 10:49 PM
Ronald S. Cook
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.

Author
23 Mar 2006 11:27 PM
Herfried K. Wagner [MVP]
"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/>
Author
23 Mar 2006 11:53 PM
Armin Zingler
"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
Author
24 Mar 2006 10:32 PM
Ronald S. Cook
So how can I assign a function key (e.g. F3) to a button?

Thanks.

Show quoteHide quote
"Armin Zingler" <az.nospam@freenet.de> wrote in message
news:OTJl4YtTGHA.5464@TK2MSFTNGP10.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
Author
25 Mar 2006 12:10 AM
Armin Zingler
"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.aspx?scid=kb;en-us;839201


http://msdn.microsoft.com/library/en-us/vbcon/html/vbconMouseKeyboardInteractions.asp



Armin
Author
26 Mar 2006 10:44 PM
Dennis
You can also use mybutton.performclick.
--
Dennis in Houston


Show quoteHide quote
"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.aspx?scid=kb;en-us;839201
>
>
> http://msdn.microsoft.com/library/en-us/vbcon/html/vbconMouseKeyboardInteractions.asp
>
>
>
> Armin
>
>
Author
27 Mar 2006 9:20 AM
Armin Zingler
"Dennis" <Den***@discussions.microsoft.com> schrieb
> You can also use mybutton.performclick.


Yes, you can, but I never suggest it because no button has been clicked.


Armin