的SendKeys ::发送,抓狂 [英] SendKeys::Send, going berserk

查看:122
本文介绍了的SendKeys ::发送,抓狂的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想进行更新,以两个链接文本框上课。我禁用一个事件,然后发送邮件使用的按键,例如的SendKeys ::发送(A); 最早给予其焦点:

I am trying to make updates to two linked TextBoxes. 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);

它的几乎的作品,但进入完全的精神,而不是重复的字符(我不敢看向检查哪些确切的关键,因为我疯狂地消防溢出),直到我preSS控制中高音-del。没有其他的按键有什么影响和鼠标冻结了。但是,任务管理器奇迹般地恢复了我的控制,我不停止或它杀死任何东西。

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 manager miraculously restores my control, I don't stop or kill anything from it.

谁能指教?调试器挂在了的SendKeys ::发送(A); 语句

Can anyone advise? The debugger hangs on that SendKeys::Send("A"); statement.

推荐答案

的SendKeys 放置输入消息队列是在<排队等都会得到处理的 / EM>您已经重新连接的事件。因此,古怪。

SendKeys places input in the message queue which is queued and so will get processed after you have reconnected the events. Hence the wackiness.

我的建议是停止使用的SendKeys 来更新自己的控件中的内容。只需直接修改的文本框的内容。

My advice is to stop using SendKeys to update the contents of your own controls. Simply modify the contents of the text boxes directly.

这篇关于的SendKeys ::发送,抓狂的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆