Reputation: 6061
I'm updating an old app to use a ribbon. In one place the old version has a button that opens a small dialog to take a numeric value from the user. I'm trying to use CMFCRibbonEdit
to replace it with a textbox on the ribbon. The dialog I'm attempting to replace used DDX/DDV to control the user input. Since the ribbon is hosted in CMainFrame
, I thought I would just have to use the class wizard to add a DoDataExchange
override to the main frame; and then add a copy of the DDX/DDV code from the dialog and just update the data member/id/etc values. However after doing this, my DoDataExchange
method isn't being called when I do any editing of the contents of the textbox or leave its focus, nor are the input value restrictions being enforced.
void CMainFrame::DoDataExchange(CDataExchange* pDX)
{
CFrameWndEx::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMainFrame)
DDX_Text(pDX, ID_CALIBRATE_USER_DEFINED_EDIT, m_CalDistance);
DDV_MinMaxInt(pDX, m_CalDistance, 0, 9999);
//}}AFX_DATA_MAP
}
Upvotes: 1
Views: 542
Reputation: 15365
DoDataExchange/UpdateData is a virtual function inside CWnd but it is never called for a CFrameWnd or CToolBar or CMFCMfcRibbonBar.
You can simply override CMFCRibbonRichEditCtrl::OnKillFocus and manage all your validation here. But you have to do it manually.
It may be possible to get UpdateData to work, but in this case the parent of your ribbon edit control has to execute UpdateData, otherwise the control ID isn't found. Keep in mind that I wouldn't expect dialog messages when I enter something in a ribbon. I would expect that the data is automatically changed to its minimum or maximum.
Upvotes: 1