CMFCRibbonBar: GetEditText() doesn't return the actual edit box text of a CMFCRibbonComboBox unless window loses the focus

420 views Asked by At

I have a VS2008 project with a 'Find' panel containing an editable combo box as well as a forward and a backward search button. When I press a search button, GetEditText() returns an outdated value.

CMainFrame *pFrame = static_cast<CMainFrame*>(GetTopLevelFrame());
CMFCRibbonBar* pRibbon = pFrame->GetRibbonBar();
ASSERT_VALID(pRibbon);
CMFCRibbonComboBox* pFindCombobox = 
    DYNAMIC_DOWNCAST(CMFCRibbonComboBox, pRibbon->FindByID(ID_MY_FIND_COMBOBOX));

// this returns the last value before the combo box edit field got the focus:
pFindCombobox->GetEditText(); 

Is there a standard way to 'flush' the edit field's content to the value buffer accessed by GetEditText()?

I noticed that in VS2010 there is a SetFocused() member in the CMFCRibbonPanel class, which could be used to steal the focus from the combobox and presumably force GetEditText() to return the right value, but it is missing in VS2008.

I'm currently running out of ideas how to handle this. Hope anyone has a clue.

1

There are 1 answers

0
thomiel On

For now, I have helped myself with a SetFocus() to the MDI child window before I call GetEditText(). But it's not the nicest workaround for sure!