Print Page | Close Window

MFC. Edit Control inside RibbonBar.

Printed From: Codejock Forums
Category: General
Forum Name: Articles and Tutorials
Forum Description: Articles and Tutorials
Printed Date: 01 March 2024 at 6:37am
Software Version: Web Wiz Forums 12.04 -

Topic: MFC. Edit Control inside RibbonBar.
Posted By: Oleg
Subject: MFC. Edit Control inside RibbonBar.
Date Posted: 15 March 2011 at 2:31am

When Ribbonbar has CXTPControlComboBox or CXTPConrtolEdit inside, developer should synchronize its text with internal variable. In this case if user add this Edit control to Quick Access both of them will show same text if user change it.


1. Add Edit to group

pGroupClipborad->Add(xtpControlEdit, ID_EDIT_PARAM);

2. We need add member variable that will hold actual value of Edit - in case we need check edit text, we don't have to find edit and check its current value, we just use this variable directly

CString m_strParam
m_strParam = _T("Parameter");

3. Add Handler fired when Edit is changed:


void CMainFrame::OnEditParam(NMHDR* pNMHDR, LRESULT* pResult)
CXTPControlEdit* pEdit = DYNAMIC_DOWNCAST(CXTPControlEdit, tagNMCONTROL->pControl);
if (pEdit)
m_strParam = pEdit->GetEditText();

// m_strParam contains actual text of edit. don't call GetEditText inside application. just use m_strParam instead.

*pResult = TRUE; // Handled

4.  Add Update Handler for our Edit:

void CMainFrame::OnUpdateEditParam(CCmdUI* pCmdUI)
CXTPControlEdit* pEdit = DYNAMIC_DOWNCAST(CXTPControlEdit, CXTPControl::FromUI(pCmdUI));
if (pEdit && !pEdit->HasFocus())

Now all edit with same ID_EDIT_PARAM id will always show same text

Sample project:
uploads/37/ -

Oleg, Support Team

Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 -
Copyright ©2001-2021 Web Wiz Ltd. -