Muokkaa

Jaa


CMFCAcceleratorKeyAssignCtrl Class

The CMFCAcceleratorKeyAssignCtrl class extends the CEdit Class to support extra system buttons such as ALT, CONTROL, and SHIFT.

Syntax

class CMFCAcceleratorKeyAssignCtrl : public CEdit

Members

Public Constructors

Name Description
CMFCAcceleratorKeyAssignCtrl::CMFCAcceleratorKeyAssignCtrl Constructs a CMFCAcceleratorKeyAssignCtrl object.

Public Methods

Name Description
CMFCAcceleratorKeyAssignCtrl::GetAccel Retrieves the ACCEL structure for a shortcut key pressed in the CMFCAcceleratorKeyAssignCtrl object.
CMFCAcceleratorKeyAssignCtrl::IsFocused
CMFCAcceleratorKeyAssignCtrl::IsKeyDefined Determines whether a shortcut key has been defined.
CMFCAcceleratorKeyAssignCtrl::PreTranslateMessage Used by class CWinApp to translate window messages before they are dispatched to the TranslateMessage and DispatchMessage Windows functions. (Overrides CWnd::PreTranslateMessage.)
CMFCAcceleratorKeyAssignCtrl::ResetKey Resets the shortcut key.

Remarks

This class extends the functionality of the CEdit class by supporting shortcut keys, also known as accelerator keys. The CMFCAcceleratorKeyAssignCtrl class functions as a CEdit Class and it can also recognize system buttons.

This class maps physical shortcut key combinations to string values. For example, assume the key combination ALT + B is mapped to the string "Alt + B". When the user presses this key combination in a CMFCAcceleratorKeyAssignCtrl object, "Alt + B" is displayed to the user. For more information about the mapping between shortcut keys and a string format, see CMFCAcceleratorKey Class.

Example

The following example demonstrates how to construct a CMFCAcceleratorKeyAssignCtrl object and use its ResetKey method to reset the shortcut key.

CMFCAcceleratorKeyAssignCtrl *accelCtrl = new CMFCAcceleratorKeyAssignCtrl();
accelCtrl->ResetKey();

Inheritance Hierarchy

CObject

CCmdTarget

CWnd

CEdit

CMFCAcceleratorKeyAssignCtrl

Requirements

Header: afxacceleratorkeyassignctrl.h

CMFCAcceleratorKeyAssignCtrl::CMFCAcceleratorKeyAssignCtrl

Constructs a CMFCAcceleratorKeyAssignCtrl object.

CMFCAcceleratorKeyAssignCtrl();

CMFCAcceleratorKeyAssignCtrl::GetAccel

Retrieves the ACCEL structure for a shortcut key pressed in the CMFCAcceleratorKeyAssignCtrl object.

ACCEL const* GetAccel() const;

Return Value

An ACCEL structure that describes the shortcut key.

Remarks

Use this function to retrieve the ACCEL structure for a shortcut key that the user entered into your CMFCAcceleratorKeyAssignCtrl object.

CMFCAcceleratorKeyAssignCtrl::IsFocused

For more detail see the source code located in the VC\atlmfc\src\mfc folder of your Visual Studio installation.

BOOL IsFocused() const;

Return Value

Remarks

CMFCAcceleratorKeyAssignCtrl::IsKeyDefined

Determines whether a shortcut key has been defined in the CMFCAcceleratorKeyAssignCtrl object.

BOOL IsKeyDefined() const;

Return Value

Nonzero if the user has already pressed a valid combination of keys that define a shortcut key; otherwise 0.

Remarks

Use this function to determine whether the user entered a valid shortcut key in your CMFCAcceleratorKeyAssignCtrl object. If a shortcut key exists, you can use CMFCAcceleratorKeyAssignCtrl::GetAccel method to obtain the ACCEL structure associated with this shortcut key.

CMFCAcceleratorKeyAssignCtrl::PreTranslateMessage

For more detail see the source code located in the VC\atlmfc\src\mfc folder of your Visual Studio installation.

virtual BOOL PreTranslateMessage(MSG* pMsg);

Parameters

[in] pMsg

Return Value

Remarks

CMFCAcceleratorKeyAssignCtrl::ResetKey

Resets the shortcut key.

void ResetKey();

Remarks

The function clears the edit control text. This includes any shortcut keys that the user pressed.

See also

Hierarchy Chart
Classes
CMFCAcceleratorKey Class