Keyboard shorcuts & multiple forms

N

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
 
G

Guest

Noah Stein said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top