简体   繁体   English

专注于自定义控件

[英]Focus for a custom control

I am creating effectively a custom control. 我正在有效地创建自定义控件。 I went about this by simply generating a window class and creating a window with it with WS_CHILD style. 我通过简单地生成一个窗口类并使用WS_CHILD样式创建一个窗口类来解决这个问题。 Initially the control accepts keyboard input. 最初,控件接受键盘输入。 The problem I am having is that once another control in the same window receives focus, my custom control does not receive keyboard input any more. 我遇到的问题是,同一窗口中的另一个控件获得焦点后,我的自定义控件将不再接收键盘输入。 How can I obtain keyboard input from my custom control again after focus changes? 更改焦点后如何再次从自定义控件获取键盘输入?

While creating the Window pass WS_TABSTOP also along with other Window Styles. 在创建窗口时,还将WS_TABSTOP与其他窗口样式一起传递。 This will enable your custom control to get focus when user presses TAB key. 当用户按下TAB键时,这将使您的自定义控件获得焦点。 Please check the MSDN link http://msdn.microsoft.com/en-us/library/windows/desktop/ms632600(v=vs.85).aspx 请检查MSDN链接http://msdn.microsoft.com/en-us/library/windows/desktop/ms632600(v=vs.85).aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM