CMFCRibbonEdit Class

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at CMFCRibbonEdit Class.

Implements an edit control that is located on a ribbon bar.

Syntax

class CMFCRibbonEdit : public CMFCRibbonButton  

Members

Public Constructors

Name Description
CMFCRibbonEdit::CMFCRibbonEdit Constructs a CMFCRibbonEdit object.

Public Methods

Name Description
CMFCRibbonEdit::CanBeStretched Indicates whether the height of the CMFCRibbonEdit control can increase vertically to the height of a ribbon row.
CMFCRibbonEdit::CMFCRibbonEdit Constructs a CMFCRibbonEdit object.
CMFCRibbonEdit::CopyFrom Copies the state of the specified CMFCRibbonEdit object to the current CMFCRibbonEdit object.
CMFCRibbonEdit::CreateEdit Creates a new text box for the CMFCRibbonEdit object.
CMFCRibbonEdit::DestroyCtrl Destroys the CMFCRibbonEdit object.
CMFCRibbonEdit::DropDownList Drops down a list box.
CMFCRibbonEdit::EnableSpinButtons Enables and sets the range of the spin button for the text box.
CMFCRibbonEdit::GetCompactSize Retrieves the compact size of the CFMCRibbonEdit object.
CMFCRibbonEdit::GetEditText Retrieves the text in the text box.
CMFCRibbonEdit::GetIntermediateSize Retrieves the intermediate size of the CMFCRibbonEdit object.
CMFCRibbonEdit::GetTextAlign Retrieves the alignment of the text in the text box.
CMFCRibbonEdit::GetWidth Retrieves the width, in pixels, of the CMFCRibbonEdit control.
CMFCRibbonEdit::HasCompactMode Indicates whether the display size for the CMFCRibbonEdit control can be compact.
CMFCRibbonEdit::HasFocus Indicates whether the CMFCRIbbonEdit control has the focus.
CMFCRibbonEdit::HasLargeMode Indicates whether the display size for the CMFCRibbonEdit control can be large.
CMFCRibbonEdit::HasSpinButtons Indicates whether the text box has a spin button.
CMFCRibbonEdit::IsHighlighted Indicates whether the CMFCRibbonEdit control is highlighted.
CMFCRibbonEdit::OnAfterChangeRect Called by the framework when the dimensions of the display rectangle for the CMFCRibbonEdit control changes.
CMFCRibbonEdit::OnDraw Called by the framework to draw the CMFCRibbonEdit control.
CMFCRibbonEdit::OnDrawLabelAndImage Called by the framework to draw the label and image for the CMFCRibbonEdit control.
CMFCRibbonEdit::OnDrawOnList Called by the framework to draw the CMFCRibbonEdit control in a commands list box.
CMFCRibbonEdit::OnEnable Called by the framework to enable or disable the CMFCRibbonEdit control.
CMFCRibbonEdit::OnHighlight Called by the framework when the pointer enters or leaves the bounds of the CMFCRibbonEdit control.
CMFCRibbonEdit::OnKey Called by the framework when the user presses a keytip and the CMFCRibbonEdit control has the focus.
CMFCRibbonEdit::OnLButtonDown Called by the framework to update the CMFCRibbonEdit control when the user presses the left mouse button on the control.
CMFCRibbonEdit::OnLButtonUp Called by the framework when the user releases the left mouse button.
CMFCRibbonEdit::OnRTLChanged Called by the framework to update the CMFCRibbonEdit control when the layout changes direction.
CMFCRibbonEdit::OnShow Called by the framework to show or hide the CMFCRibbonEdit control.
CMFCRibbonEdit::Redraw Updates the display of the CMFCRibbonEdit control.
CMFCRibbonEdit::SetACCData Sets the accessibility data for the CMFCRibbonEdit object.
CMFCRibbonEdit::SetEditText Sets the text in the text box.
CMFCRibbonEdit::SetTextAlign Sets the text alignment of the text box.
CMFCRibbonEdit::SetWidth Sets the width of the text box for the CMFCRibbonEdit control.

Remarks

Example

The following example demonstrates how to construct a CMFCRibbonEdit object, show spin buttons next to the edit control, and set the text of the edit control. This code snippet is part of the MS Office 2007 Demo sample.

    CMFCRibbonEdit* pEditIndentLeft = new CMFCRibbonEdit(ID_PAGELAYOUT_INDENT_LEFT, 72, _T("Left:\nil"), 13);
    // specify the min and max value of the spin button control
    pEditIndentLeft->EnableSpinButtons(0, 1000);
    // set the text of the edit control
    pEditIndentLeft->SetEditText(_T("0"));

Requirements

Header: afxRibbonEdit.h

CMFCRibbonEdit::CanBeStretched

Indicates whether the height of the CMFCRibbonEdit control can increase vertically to the height of a ribbon row.

virtual BOOL CanBeStretched();

Return Value

Always returns FALSE.

Remarks

CMFCRibbonEdit::CMFCRibbonEdit

Constructs a CMFCRibbonEdit object.

CMFCRibbonEdit(
    UINT nID,  
    int nWidth,  
    LPCTSTR lpszLabel = NULL,  
    int nImage = -1);

CMFCRibbonEdit();

Parameters

[in] nID
Command ID for the CMFCRibbonEdit control.

[in] nWidth
The width, in pixels, of the text box for the CMFCRibbonEdit control.

[in] lpszLabel
The label for the CMFCRibbonEdit control.

[in] nImage
Index of the small image to use for the CMFCRibbonEdit control. The collection of small images is maintained by the parent ribbon category.

Remarks

The CMFCRibbonEdit control does not use a large image.

CMFCRibbonEdit::CopyFrom

Copies the state of the specified CMFCRibbonEdit object to the current CMFCRibbonEdit object.

virtual void CopyFrom(const CMFCRibbonBaseElement& src);

Parameters

[in] src
The source CMFCRibbonEdit object.

Remarks

The src parameter must be of type CMFCRibbonEdit.

CMFCRibbonEdit::CreateEdit

Creates a new text box for the CMFCRibbonEdit object.

virtual CMFCRibbonRichEditCtrl* CreateEdit(
    CWnd* pWndParent,  
    DWORD dwEditStyle);

Parameters

[in] pWndParent
A pointer to the parent window of the CMFCRibbonEdit object.

[in] dwEditStyle
Specifies the style of the text box. You can combine the window styles listed in the Remarks section with the edit control styles that are described in the Windows SDK.

Return Value

A pointer to the new text box if the method was successful; otherwise, NULL.

Remarks

Override this method in a derived class to create a custom text box.

You can apply the following Window Styles to a text box:

  • WS_CHILD

  • WS_VISIBLE

  • WS_DISABLED

  • WS_GROUP

  • WS_TABSTOP

CMFCRibbonEdit::DestroyCtrl

Destroys the CMFCRibbonEdit object.

virtual void DestroyCtrl();

Remarks

CMFCRibbonEdit::DropDownList

Drops down a list box.

virtual void DropDownList();

Remarks

By default this method does nothing. Override this method to drop down a list box.

CMFCRibbonEdit::EnableSpinButtons

Enables and sets the range of the spin button for the text box.

void EnableSpinButtons(
    int nMin,  
    int nMax);

Parameters

[in] nMin
The minimum value of the spin button.

[in] nMax
The maximum value of the spin button.

Remarks

Spin buttons display an up and down arrow and enable users to move through a fixed set of values.

CMFCRibbonEdit::GetCompactSize

Retrieves the compact size of the CMFCRibbonEdit object.

virtual CSize GetCompactSize(CDC* pDC);

Parameters

[in] pDC
Pointer to a device context for the CMFCRibbonEdit object.

Return Value

The compact size of the CMFCRibbonEdit object.

Remarks

CMFCRibbonEdit::GetEditText

Retrieves the text in the text box.

CString GetEditText() const;  

Return Value

The text in the text box.

Remarks

CMFCRibbonEdit::GetIntermediateSize

Retrieves the intermediate size of the CMFCRibbonEdit object.

virtual CSize GetIntermediateSize(CDC* pDC);

Parameters

[in] pDC
Pointer to a device context for the CMFCRibbonEdit object.

Return Value

The intermediate size of the CMFCRibbonEdit object.

Remarks

CMFCRibbonEdit::GetTextAlign

Retrieves the alignment of the text in the text box.

int GetTextAlign() const;  

Return Value

A text alignment enumerated value. See the Remarks section for possible values.

Remarks

The returned value is one of the following edit control styles:

  • ES_LEFT for left alignment

  • ES_CENTER for center alignment

  • ES_RIGHT for right alignment

For more information about these styles, see Edit Control Styles.

CMFCRibbonEdit::GetWidth

Retrieves the width, in pixels, of the CMFCRibbonEdit control.

int GetWidth(BOOL bInFloatyMode = FALSE) const;  

Parameters

[in] bInFloatyMode
TRUE if the CMFCRibbonEdit control is in floating mode; otherwise, FALSE.

Return Value

The width, in pixels, of the CMFCRibbonEdit control.

Remarks

CMFCRibbonEdit::HasCompactMode

Indicates whether the display size for the CMFCRibbonEdit control can be compact.

virtual BOOL HasCompactMode() const;  

Return Value

Always returns TRUE.

Remarks

By default this method always returns TRUE. Override this method to indicate whether the display size can be compact.

CMFCRibbonEdit::HasFocus

Indicates whether the CMFCRibbonEdit control has the focus.

virtual BOOL HasFocus() const;  

Return Value

TRUE if the CMFCRibbonEdit control has the focus; otherwise FALSE.

Remarks

CMFCRibbonEdit::HasLargeMode

Indicates whether the display size for the CMFCRibbonEdit control can be large.

virtual BOOL HasLargeMode() const;  

Return Value

Always returns FALSE.

Remarks

By default this method always returns FALSE. Override this method to indicate whether the display size can be large.

CMFCRibbonEdit::HasSpinButtons

Indicates whether the text box has a spin button.

virtual BOOL HasSpinButtons() const;  

Return Value

TRUE if the text box has a spin button; otherwise FALSE.

Remarks

CMFCRibbonEdit::IsHighlighted

Indicates whether the CMFCRibbonEdit control is highlighted.

virtual BOOL IsHighlighted() const;  

Return Value

TRUE if the CMFCRibbonEdit control is highlighted; otherwise FALSE.

Remarks

CMFCRibbonEdit::OnAfterChangeRect

Called by the framework when the dimensions of the display rectangle for the CMFCRibbonEdit control change.

virtual void OnAfterChangeRect(CDC* pDC);

Parameters

[in] pDC
Pointer to a device context for the CMFCRibbonEdit control.

Remarks

CMFCRibbonEdit::OnDraw

Called by the framework to draw the CMFCRibbonEdit control.

virtual void OnDraw(CDC* pDC);

Parameters

[in] pDC
Pointer to a device context for the CMFCRibbonEdit control.

Remarks

CMFCRibbonEdit::OnDrawLabelAndImage

Called by the framework to draw the label and image for the CMFCRibbonEdit control.

virtual void OnDrawLabelAndImage(CDC* pDC);

Parameters

[in] pDC
Pointer to a device context for the CMFCRibbonEdit control.

Remarks

CMFCRibbonEdit::OnDrawOnList

Called by the framework to draw the CMFCRibbonEdit control in a commands list box.

virtual void OnDrawOnList(
    CDC* pDC,  
    CString strText,  
    int nTextOffset,  
    CRect rect,  
    BOOL bIsSelected,  
    BOOL bHighlighted);

Parameters

[in] pDC
Pointer to a device context for the CMFCRibbonEdit control.

[in] strText
The display text bb983822(v=vs.140).md.

[in] nTextOffset
Distance, in pixels, from the left side of the list box to the display text.

[in] rect
The display rectangle for the CMFCRibbonEdit control.

[in] bIsSelected
This parameter is not used.

[in] bHighlighted
This parameter is not used.

Remarks

The commands list box displays ribbon controls to enable users to customize the quick access toolbar.

CMFCRibbonEdit::OnEnable

Called by the framework to enable or disable the CMFCRibbonEdit control.

virtual void OnEnable(BOOL bEnable);

Parameters

[in] bEnable
TRUE to enable the control; FALSE to disable the control.

Remarks

CMFCRibbonEdit::OnHighlight

Called by the framework when the pointer enters or leaves the bounds of the CMFCRibbonEdit control.

virtual void OnHighlight(BOOL bHighlight);

Parameters

[in] bHighlight
TRUE if the pointer is in the bounds of the CMFCRibbonEdit control; otherwise, FALSE.

Remarks

CMFCRibbonEdit::OnKey

Called by the framework when the user presses a keytip and the CMFCRibbonEdit control has the focus.

virtual BOOL OnKey(BOOL bIsMenuKey);

Parameters

[in] bIsMenuKey
TRUE if the keytip displays a pop-up menu; otherwise, FALSE.

Return Value

TRUE if the event was handled; otherwise, FALSE.

Remarks

CMFCRibbonEdit::OnLButtonDown

Called by the framework to update the CMFCRibbonEdit control when the user presses the left mouse button on the control.

virtual void OnLButtonDown(CPoint point);

Parameters

[in] point
This parameter is not used.

Remarks

CMFCRibbonEdit::OnLButtonUp

Called by the framework when the user releases the left mouse button.

virtual void OnLButtonUp(CPoint point);

Parameters

[in] point
This parameter is not used.

Remarks

CMFCRibbonEdit::OnRTLChanged

Called by the framework to update the CMFCRibbonEdit control when the layout changes direction.

virtual void OnRTLChanged(BOOL bIsRTL);

Parameters

[in] bIsRTL
TRUE if the layout is right-to-left; FALSE if the layout is left-to-right.

Remarks

CMFCRibbonEdit::OnShow

Called by the framework to show or hide the CMFCRibbonEdit control.

virtual void OnShow(BOOL bShow);

Parameters

[in] bShow
TRUE to show the control; FALSE to hide the control.

Remarks

CMFCRibbonEdit::Redraw

Updates the display of the CMFCRibbonEdit control.

virtual void Redraw();  

Remarks

This method redraws the display rectangle for the CMFCRibbonEdit object by indirectly calling CWnd::RedrawWindow with the RDW_INVALIDATE, RDW_ERASE, and RDW_UPDATENOW flags set.

CMFCRibbonEdit::SetACCData

Sets the accessibility data for the CMFCRibbonEdit object.

virtual BOOL SetACCData(
    CWnd* pParent,  
    CAccessibilityData& data);

Parameters

pParent
Pointer to the parent window for the CMFCRibbonEdit object.

data
The accessibility data for the CMFCRibbonEdit object.

Return Value

Always returns TRUE.

Remarks

CMFCRibbonEdit::SetEditText

Sets the text in the text box.

void SetEditText(CString strText);

Parameters

[in] strText
The text for the text box.

CMFCRibbonEdit::SetTextAlign

Sets the text alignment of the text box.

void SetTextAlign(int nAlign);

Parameters

[in] nAlign
A text alignment enumerated value. See the Remarks section for possible values.

Remarks

The parameter nAlign is one of the following edit control styles:

  • ES_LEFT for left alignment

  • ES_CENTER for center alignment

  • ES_RIGHT for right alignment

For more information about these styles, see Edit Control Styles.

CMFCRibbonEdit::SetWidth

Sets the width of the text box for the CMFCRibbonEdit control.

void SetWidth(
    int nWidth,  
    BOOL bInFloatyMode = FALSE);

Parameters

[in] nWidth
The width, in pixels, of the text box.

bInFloatyMode
TRUE to set the width for floating mode; FALSE to set the width for regular mode.

Remarks

The CMFCRibbonEdit control has two widths depending on its display mode: floating mode and regular mode.

See Also

Hierarchy Chart
Classes
CMFCRibbonButton Class
CMFCRibbonBar Class