Home All Groups Group Topic Archive Search About

Keyboard shorcuts & multiple forms

Author
16 Jun 2006 12:46 AM
Noah Stein
I'd like to add keyboard shorcuts to my program. I'm writing an application
that has many top-level forms that reside on the desktop. When the focus is
one form, other forms can't respond to short cuts. Some of my shortcuts are
program-wide. What are my options? I see a few:

1) Add each short cut to each form (bad)
2) Have each form call a central function to check program-wide keys (not as
bad)
3) Add a message filter on the application (pretty bad)

Is there some really simple, elegant way that I've missed. In MFC's message
routine, the application object could respond to any short cut messages. Is
there anything similar in .NET?


Thanks,
Noah

Author
19 Jun 2006 3:52 PM
Mini-Tools Timm
Show quote
"Noah Stein" wrote:

> I'd like to add keyboard shorcuts to my program. I'm writing an application
> that has many top-level forms that reside on the desktop. When the focus is
> one form, other forms can't respond to short cuts. Some of my shortcuts are
> program-wide. What are my options? I see a few:
>
> 1) Add each short cut to each form (bad)
> 2) Have each form call a central function to check program-wide keys (not as
> bad)
> 3) Add a message filter on the application (pretty bad)
>
> Is there some really simple, elegant way that I've missed. In MFC's message
> routine, the application object could respond to any short cut messages. Is
> there anything similar in .NET?

Actually #3 is not that bad.  You can add your own message filter with
Application.AddMessageFilter and intercept all keyboard input in your
application.

We offer a .NET component that's FREE for non-commercial use that will do
all this for you:

http://www.mini-tools.com/goto/input

--
Timm Martin
Mini-Tools
..NET Components and Windows Software
http://www.mini-tools.com

AddThis Social Bookmark Button