MFC. Edit Control inside RibbonBar. |
Post Reply |
Author | |
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
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. Steps 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: ON_XTP_EXECUTE(ID_EDIT_PARAM, OnEditParam) void CMainFrame::OnEditParam(NMHDR* pNMHDR, LRESULT* pResult) { NMXTPCONTROL* tagNMCONTROL = (NMXTPCONTROL*)pNMHDR; 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()) { pEdit->SetEditText(m_strParam); } pCmdUI->Enable(TRUE); } Now all edit with same ID_EDIT_PARAM id will always show same text Sample project:
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |