Need help for Ctrl-Tab Hot Key

G

Glen Hong

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
 
W

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/
 
G

Glen Hong

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
 
W

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/
 

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