禁用对话框中的所有按钮后无法返回关键焦点 [英] Unable to get back key focus after disabling all buttons in a dialog

查看:79
本文介绍了禁用对话框中的所有按钮后无法返回关键焦点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的专家,


我在Windows Server 2008 R2下使用Visual Studio 2008(带SP1)。 


I编写了一个包含多个按钮的MPC对话框,该对话框还可以通过处理PreTranslateMessage函数中的键输入消息来响应某些键输入。


我发现如果我调用EnableWindow(FALSE) )对于所有按钮,即使我为所有按钮调用EnableWindow(TRUE),并为对话窗口调用SetForegroundWindow(),程序仍然无法响应按键输入。但是,如果我将任何按钮保留为
仍然启用(当我调用EnableWindow(FALSE))其他按钮时,程序可以在我再次启用所有按钮后响应按键输入。


这是什么原因?我应该怎么做才能让程序在禁用后响应键输入然后启用对话框中的所有按钮?


谢谢。


问候,Simon


解决方案

嗨Simon Tong,


<谢谢你在这里发帖。


>>这是什么原因?我应该怎么做,以便程序可以在禁用后响应键输入,然后启用对话框中的所有按钮?


很抱歉,我无法重现您的问题。我在VS 2015 MFC项目中创建的对话框,当我禁用其中的所有按钮时,它可以接收键盘输入。例如,Ctrl + V



您能否提供有关如何使用EnableWindow的更多信息?


请使用按钮对象来调用此方法 并尝试使用
SetFocus
功能将键盘焦点设置回对话框。


希望这可能有助于你好。


最好的问候,


Sera Yu



Dear expert,

I am using Visual Studio 2008 (with SP1) under Windows Server 2008 R2. 

I have programmed an MPC dialog that contains several buttons, the dialog can also respond on some key input by handling the key input message within the PreTranslateMessage function.

I found that if I call EnableWindow(FALSE) for all buttons, even I call EnableWindow(TRUE) for all of them, and call SetForegroundWindow() for the dialog window, the program still cannot respond key press input. However, if I keep anyone of the button to remain be enabled (while I call EnableWindow(FALSE)) for the other buttons, the program can respond to key press input after I enable all of the buttons again.

What's the reason of that? What should I do such that the program can respond to key input after I disabled and then enabled all buttons in a dialog?

Thanks.

Regards, Simon

解决方案

Hi Simon Tong,

thanks for posting here.

>>What's the reason of that? What should I do such that the program can respond to key input after I disabled and then enabled all buttons in a dialog?

Sorry that I can't reproduce your problem. My dialog which is created in my VS 2015 MFC project, it could receive keyboard input when I disable all buttons in it. For example, Ctrl+V

Could you please provide more information about how you use EnableWindow?

Please use button object to call this method and try to use SetFocus function to set the keyboard focus back to the dialog.

Hope this could be help of you.

Best Regards,

Sera Yu


这篇关于禁用对话框中的所有按钮后无法返回关键焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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