I'm having trouble trying to update the caption (text element) of an Edit box in MFC.
Below. is what I currently tried. I know I am grabbing the correct element because I can see that the tooltip has changed. The caption text next to the edit box just changes to blank
*Update: After further collaboration with a senior programmer, we've found this is most likely an MFC bug. I'd love to be proven wrong though because the work-around involves splitting the edit box into a label and a box, which is less than ideal due to alignment issues.
CMFCRibbonBaseElement* pEditBox = (CMFCRibbonBaseElement*)m_wndRibbon.FindByID(EDIT_BOX_ID);
pEditBox->SetText(_T("new Text"));
pEditBox->SetToolTipText(_T("tool tip text"));
I can also see using the debugger that m_strText, which in this case is the caption, is being changed. Am I missing a step where I need to re-render the text for it to show up? The only thing I could think of was calling pEditBox->Redraw(); after setting the text, but this did nothing.
The other approach I tried below was to use SetText in an update function, but this just changes the text in the box, not the title. I thought this might work because I was able to change the text next to a checkbox using this approach.
ON_UPDATE_COMMAND_UI(EDIT_BOX_ID, &CMyDoc::OnUpdateEditBoxText);
void CMyDoc::OnUpdateEditBoxText(CCmdUI *pCmdUI)
{
if (//my condition)
pCmdUI->SetText(_T("new Text"));
}
Another approach I could take is just having the box disappear but pEditBox->SetVisible(FALSE); doesn't work for this edit box either.