我在MFC应用程序中遇到以下问题:
即使控件具有焦点,控件中的焦点矩形也不会始终显示。
重现步骤:
启动应用程序 点击控件 焦点矩形未显示: 使用Alt-Tab切换到另一个应用程序 切换回我的应用程序 点击控件 现在焦点矩形按预期显示: 从现在开始,控件上的焦点矩形会在获得焦点时正确显示。这就像有两个“模式”,一个是显示焦点矩形,另一个是未显示。
其他事实:
控件确实具有焦点,因为使用向上/向下箭头键更改所选项目 它在Windows 10上运行 当我们处于未显示焦点矩形的“模式”时,程序的行为保持正确。有人遇到过这样的问题吗? 我想知道这是否是一些“聪明”的微软功能。
I'm encountering following problem in my MFC application:
The focus rectangle in controls is not always showing up, even if the control has the focus.
Steps to reproduce:
starting the application clicking on the control focus rectangle is not shown: switching to another application with Alt-Tab switching back to my application clicking on the control now the focus rectangle is shown as expected: from now on the focus rectangles on controls are shown correctly as they gain focus.It's like there were two "modes" one where focus rectangles are shown and one where they are not shown.
Other facts:
the control really does have the focus, as changing the selected item works using the up/down arrow keys it's running on Windows 10 when we are in the "mode" where the focus rectangles are not shown, the behaviour of the program remains correct.Has anybody encountered such a problem? I wonder if this is some "clever" Microsoft feature.
最满意答案
这是一个称为“键盘提示”( SPI_GETKEYBOARDPREF和SPI_GETKEYBOARDCUES )的Windows功能,Windows的新版本默认在基于对话框的窗口中隐藏它们(焦点矩形和带下划线的键盘访问键)。 此功能是在Windows 2000中引入的 。
Windows对话框管理器根据最后一个输入 (鼠标或键盘)初始化对话框:
窗口的默认状态是显示所有指标。 但作为一个特殊技巧,对话框管理器将在初始化对话框后发送带有UIS_INITIALIZE的WM_UPDATEUISTATE消息,如果最后一个输入事件是鼠标事件,则会关闭指示符。
您可以使用MAKELONG(UIS_CLEAR, UISF_HIDEFOCUS)将WM_UPDATEUISTATE消息发布到对话框窗口,以显示焦点矩形(如果您希望覆盖Windows默认值)。
This is a Windows feature known as "Keyboard Cues" (SPI_GETKEYBOARDPREF and SPI_GETKEYBOARDCUES) and newer versions of Windows defaults to hiding them (focus rectangle and underlined keyboard access keys) in dialog based windows. This feature was introduced in Windows 2000.
The Windows dialog manager initializes dialogs based on the last input (mouse or keyboard):
The default state for a window is to show all indicators. But as a special trick, the dialog manager will send a WM_UPDATEUISTATE message with UIS_INITIALIZE after the dialog has been initialized, which turns off the indicators if the last input event was a mouse event.
You can post a WM_UPDATEUISTATE message to your dialog window with MAKELONG(UIS_CLEAR, UISF_HIDEFOCUS) to display the focus rectangle (if you wish to override the Windows defaults).
更多推荐
focus,焦点,shown,显示,电脑培训,计算机培训,IT培训"/> <meta name="description
发布评论