PC Review


Reply
Thread Tools Rate Thread

Dialog Handling Shortcut keys

 
 
Emma Middlebrook
Guest
Posts: n/a
 
      24th May 2007
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

 
Reply With Quote
 
 
 
 
Jon Skeet [C# MVP]
Guest
Posts: n/a
 
      24th May 2007
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

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Vista File Dialog shortcut keys flybynight Windows XP Accessibility 0 2nd Sep 2008 12:17 PM
shortcut keys - howto find shortcut keys coltrane Microsoft Windows 2000 0 1st Jun 2005 03:25 PM
AddFavorite Method doesn't work like AddFavorite Dialog or CTRL-D handling Shortcut ICONs Mel in Roseville Windows XP Internet Explorer 2 11th May 2005 01:40 PM
Simulating Access shortcut keys, and trapping F-keys press Amir Microsoft Access Forms 2 14th Aug 2004 05:21 AM
Shortcut keys (Access keys) problem =?Utf-8?B?VGltIFBhdHJpY2s=?= Microsoft Dot NET Framework Forms 0 2nd Feb 2004 04:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:00 AM.