472,127 Members | 2,005 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,127 software developers and data experts.

Need help for Ctrl-Tab Hot Key

I have set up a hotkey using RegisterHotKey API function for Ctrl-Tab.

Firstly, I can rap this when Ctrl-Tab is pressed however if I want to
add an addition hotkey how can I distinguish between which hotkey was
pressed?

Secondly I am trying to replicate the Ctrl-Tab functionality you have
in the DotNet IDE when you hold down the Ctrl key and then additional
use the tab key you can cycle thru the MDI Children. I would like to
gain the same functionality but don't know how to catch the initial
Ctrl Key down and then Ctrl Key up and then also catch when the tab
key has been pressed?

Really appreciate any ideas.

Thanks
Nov 16 '05 #1
3 6978
Wes
Hello Glen, (Comments inline)
I have set up a hotkey using RegisterHotKey API function for Ctrl-Tab.

Firstly, I can rap this when Ctrl-Tab is pressed however if I want to
add an addition hotkey how can I distinguish between which hotkey was
pressed?
The second parameter to RegisterHotKey is an ID for that particular hotkey. Just give different IDs for different hotkeys and when you get the WM_HOTKEY message check the lParam for the particular ID of the hotkey and do the action for the appropriate hotkey.
Secondly I am trying to replicate the Ctrl-Tab functionality you have
in the DotNet IDE when you hold down the Ctrl key and then additional
use the tab key you can cycle thru the MDI Children. I would like to
gain the same functionality but don't know how to catch the initial
Ctrl Key down and then Ctrl Key up and then also catch when the tab
key has been pressed?


Since CTRL is a modifier key you can't capture that alone as a hotkey however it should trigger your hotkey when each time the user is holding the CTRL key and hits the Tab key. i.e. Hold CTRL hit Tab, Triggers Hotkey, Still Holding CTRL but release Tab, and then Press Tab again it should Trigger the Hotkey again.

HTH
Wes Haggard
http://weblogs.asp.net/whaggard/
Nov 16 '05 #2
Hi Wes,

Thanks for the reply! What you have said does work, unfortunately
there is a need to realise when the ctrl tab has been released. When
you hold down the ctrl key you continue to cycle thru the mdi
children. Whenever you release the ctrl key the cycling finishes and
the mdi list is then rearranged.

Do you think there is a way of doing this? Also I think I have just
discovered that the RegisterHotKey function registers that hot key for
all of windows. i.e. Even applies when the application does not have
the focus. Is there a way of registering a hotkey for an application
only when it has the focus??

Thanks
Nov 16 '05 #3
Wes
Hello Glen,
Hi Wes,

Thanks for the reply! What you have said does work, unfortunately
there is a need to realise when the ctrl tab has been released. When
you hold down the ctrl key you continue to cycle thru the mdi
children. Whenever you release the ctrl key the cycling finishes and
the mdi list is then rearranged.

Do you think there is a way of doing this? Also I think I have just
discovered that the RegisterHotKey function registers that hot key for
all of windows. i.e. Even applies when the application does not have
the focus. Is there a way of registering a hotkey for an application
only when it has the focus??


You are correct RegisterHotkey registers a global hotkey so your application doesn't have to be active to get the hotkey. I'm assuming you are using WinForms and if so you could easily either override the KeyUp/KeyDown events to do what you want.

So you could do something like:

protected override OnKeyDown(KeyEventArgs e)
{
if(e.KeyCode == Keys.Tab && e.Control)
// Cycle through windows, i.e. move to next window

base.OnKeyDown(e);
}

If I'm understanding what you are trying to do I believe that will do it.

HTH
Wes Haggard
http://weblogs.asp.net/whaggard/
Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Scott | last post: by
1 post views Thread by Stefan W via .NET 247 | last post: by
3 posts views Thread by Eirik Eldorsen | last post: by
2 posts views Thread by s99999999s2003 | last post: by
11 posts views Thread by Bookham Measures | last post: by
reply views Thread by leo001 | last post: by

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.