大网数据广告活动
Windows 系统接口

Keyboard Handling for Controls

· 52CE 我爱测

A control responds to keyboard accelerators so the end-user can initiate actions performed by the control.

A control responds to keyboard accelerators so the end-user can initiate actions performed by the control. The container manages keyboard activity for all its embedded controls. With compound documents, keyboard accelerators apply only to the currently active object. With controls, a mechanism has been added so that a control can respond to its keyboard mnemonics even if it is not currently UI-active.

The IOleControl::GetControlInfo and IOleControl::OnMnemonic methods and the IOleControlSite::OnControlInfoChanged method handle a control's keyboard mnemonics. A CONTROLINFO structure describes a control's mnemonic accelerators, and the flags passed back with it through the GetControlInfo method describe the controls behavior with the Enter and Esc keys. When a control changes its mnemonics, it calls OnControlInfoChanged so the container can reload the structure if necessary.

When a control is UI active, it is also the control with the focus. As controls are activated and deactivated between the in-place active and the UI active states, the control calls IOleControlSite::OnFocus to tell the container of such changes.

In addition, when a control is UI active, it will have first chance to process any keystrokes. To give a container the opportunity to process the keystroke before the control, the control calls IOleControlSite::TranslateAccelerator. If the container does not handle the keystroke, the control then processes it.

Related topics

ActiveX Controls

Source: Microsoft Learn / Windows Win32 documentation by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Win32 documentation
适用范围
Windows Win32 API · Source date 05/31/2018
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。