Codejock Forums Homepage
Forum Home Forum Home > General > Articles and Tutorials
  New Posts New Posts RSS Feed - MFC. Edit Control inside RibbonBar.
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

MFC. Edit Control inside RibbonBar.

 Post Reply Post Reply
Author
Message
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Topic: MFC. Edit Control inside RibbonBar.
    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
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

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

This page was generated in 0.141 seconds.