469,572 Members | 1,224 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,572 developers. It's quick & easy.

Dialog Handling Shortcut keys

Hi there,

I'm trying to handle some shortcut keys within my application and I
can't seem to get the code to work when you are trying to action
against a ctrl + other character.

I found a post
http://groups.google.co.uk/group/mic...cbc8062c107680
that appears to help a lot but it doesn't seem to work with the ctrl
key.

here's the snippet of code I am working with, which was modified from
the thread mentioned above:

protected override bool ProcessDialogKey(Keys keyData)
{
if (keyData == Keys.ControlKey && keyData == Keys.G)
{
ReassignAssessment();
}
else if (keyData == Keys.Insert)
{
ToggleReadUnread();
}

return base.ProcessDialogKey(keyData);
}

This method seems to be fired on every key press, so I don't even get
a chance to press "G" as the method has already fired on ctrl. Even
when I run without debugging it's showing no signs of executing.

The value of keydata when I do debug is 131089, which if I look at the
MSDN help could match to the value of Keys.Control (131072) +
Keys.ControlKey (17)

Are there any alternatives that I could try to get this to work?

Thanks,

Emma Middlebrook

May 24 '07 #1
1 2659
On May 24, 1:54 pm, Emma Middlebrook <e.middlebr...@googlemail.com>
wrote:
This method seems to be fired on every key press, so I don't even get
a chance to press "G" as the method has already fired on ctrl. Even
when I run without debugging it's showing no signs of executing.
You need to use:

if (keyData == (Keys.G | Keys.Control))
{
....
}

This will trigger if G and Ctrl are pressed, but won't trigger on:
Shift+G
G
Shift
Ctrl
Ctrl+Shift+G
Alt+G
etc

Jon

May 24 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Maurice Mertens | last post: by
reply views Thread by Saper\(ek\) | last post: by
9 posts views Thread by Lars Netzel | last post: by
3 posts views Thread by =?Utf-8?B?R3JlZw==?= | last post: by
8 posts views Thread by BD | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.