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: uploads/37/EditSample.zip - EditSample.zip
------------- Oleg, Support Team CODEJOCK SOFTWARE SOLUTIONS
|