This documentation is archived and is not being maintained.

CHotKeyCtrl Class

Provides the functionality of the Windows common hot key control.

class CHotKeyCtrl : public CWnd




Constructs a CHotKeyCtrl object.




Creates a hot key control and attaches it to a CHotKeyCtrl object.


Creates a hot key control with the specified Windows extended styles and attaches it to a CHotKeyCtrl object.


Retrieves the virtual key code and modifier flags of a hot key from a hot key control.


Retrieves the key name, in the local character set, assigned to a hot key.


Retrieves the key name, in the local character set, assigned to the specified virtual key code.


Sets the hot key combination for a hot key control.


Defines the invalid combinations and the default modifier combination for a hot key control.

A "hot key control" is a window that enables the user to create a hot key. A "hot key" is a key combination that the user can press to perform an action quickly. (For example, a user can create a hot key that activates a given window and brings it to the top of the Z order.) The hot key control displays the user's choices and ensures that the user selects a valid key combination.

This control (and therefore the CHotKeyCtrl class) is available only to programs running under Windows 95/98 and Windows NT version 3.51 and later.

When the user has chosen a key combination, the application can retrieve the specified key combination from the control and use the WM_SETHOTKEY message to set up the hot key in the system. Whenever the user presses the hot key thereafter, from any part of the system, the window specified in the WM_SETHOTKEY message receives a WM_SYSCOMMAND message specifying SC_HOTKEY. This message activates the window that receives it. The hot key remains valid until the application that called WM_SETHOTKEY exits.

This mechanism is different from the hot key support that depends on the WM_HOTKEY message and the Windows RegisterHotKey and UnregisterHotKey functions.

For more information on using CHotKeyCtrl, see Controls and Using CHotKeyCtrl.

Header: afxcmn.h