SendKeys::Send, going berserk
I am trying to make updates to two linked TextBox
es. I disable events in one and then send keystrokes using eg SendKeys::Send("A");
having first given it focus:
texBox2->Focus();
texBox2->KeyDown -= gcnew KeyEventHandler(this, &Form1::texBox2_KeyDown);
SendKeys::Send("A");
texBox2->KeyDown += gcnew KeyEventHandler(this, &Form1::texBox2_KeyDown);
It almost works but goes totally mental instead repeating the character (I daren't look to check which exact key because I'm frantically firefighting an overflow) until I press control-alt-del. No other keys have any effect and the mouse freezes up. But task man开发者_如何学编程ager miraculously restores my control, I don't stop or kill anything from it.
Can anyone advise? The debugger hangs on that SendKeys::Send("A");
statement.
SendKeys
places input in the message queue which is queued and so will get processed after you have reconnected the events. Hence the wackiness.
My advice is to stop using SendKeys
to update the contents of your own controls. Simply modify the contents of the text boxes directly.
精彩评论