Processing "Control + C" keys in RichTextBox.KeyDown()

R

Robe

Hi there,

I'm using a RichTextBox to create a custom editor, my class inherits from
it. I've set to false the property ShortcutsEnabled and I need to handle the
combination of keys Control + C. I've tried it in many ways using the
modifiers of the KeyEventArgs, using GetKeyboardState(), using GetKeyState()
in the RichEdit KeyDown event but it doesn’t work.

I think the problem is that when the user press both keys the event is not
fired for some reason, because if I check for the control key only it works
and the same for the C key but when both are pressed it doesn’t work.

Can someone explain me why this is happening?
How can I handle these keys combination?

Thank you in advance,

Robe.
 
P

Peter Duniho

Robe said:
Hi there,

I'm using a RichTextBox to create a custom editor, my class inherits from
it. I've set to false the property ShortcutsEnabled and I need to handle the
combination of keys Control + C. I've tried it in many ways using the
modifiers of the KeyEventArgs, using GetKeyboardState(), using GetKeyState()
in the RichEdit KeyDown event but it doesn’t work.

I think the problem is that when the user press both keys the event is not
fired for some reason, because if I check for the control key only it works
and the same for the C key but when both are pressed it doesn’t work.

Can someone explain me why this is happening?
How can I handle these keys combination?

The KeyEventArgs passed to your KeyDown event handler includes modifier
key state. So if you're having trouble, it's because your event handler
isn't written correctly.

For more specific advice on in what way your event handler isn't written
correctly, you will at a minimum need to post that event handler. For
best results, post a concise-but-complete code example that reliably
demonstrates the problem.

Pete
 

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