MFC DDV_MinMaxFloat does not work |
Post Reply |
Author | |
devam
Groupie Joined: 20 March 2008 Location: India Status: Offline Points: 15 |
Post Options
Thanks(0)
Posted: 02 March 2009 at 1:21am |
There is an edit box in the dialog which can take only floating point numbers
To achieve following Dialog Data Validation of MFC is used DDV_MinMaxFloat UpdateData(TRUE) will validate the values entered and and error message box is popped up automatically by the MFC Framework This is working fine in following scenarios: 1. When the Edit box is empty 2. Edit box has strings : For eg: Hello But it is not working if a string starts with a numerical value. For eg: 12Hello In this case Hello is truncated and only the value 12 is used for validation. This is not our requirement we need to pop up an error message box in this case as well. My Do DataExchange function looks something like this:
void MDSWDMOTNInterfaceDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(MDSWDMOTNInterfaceDlg::DoDat) DDX_Control(pDX, IDC_EDIT_TIME_COST, m_EditTimeCost); DDX_Control(pDX, IDC_EDIT_TIME_WAVE, m_EditTimeWave); DDX_Text(pDX, IDC_EDIT_TIME_COST, m_fTimeCost); DDX_Text(pDX, IDC_EDIT_TIME_WAVE, m_fTimeWave); DDV_MinMaxFloat(pDX,m_fTimeCost,(float)0,(float)MAX_FLOAT); DDV_MinMaxFloat(pDX,m_fTimeWave,(float)0,(float)MAX_FLOAT); DDX_Control(pDX, IDC_CUSTOM_CHECK, m_CheckCustomOptions); DDX_Control(pDX, IDC_RADIO_COST, m_RadioCostOptimiz); DDX_Control(pDX, IDC_RADIO_WAVE, m_RadioCostWaveOptimiz); DDX_Control(pDX, IDC_EDIT_OPERINFO, m_OutputEdit); DDX_Text(pDX, IDC_EDIT_OPERINFO, m_strOpraInfo); DDX_Control(pDX, IDC_BUTTON_PLAN, m_PlanButton); //}}AFX_DATA_MAP} Please let me know what is the reason for this and how to resolve it without writing our own code for validations. |
|
DC
|
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
Hi,
guess you need create own DDX_Text for such edit. See original one and change it.
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
devam
Groupie Joined: 20 March 2008 Location: India Status: Offline Points: 15 |
Post Options
Thanks(0)
|
Hi Oleg,
Thanks for the response. But I have already mentioned in the problem description that I want to know why this is happening, and if there is any solution available without having to code for validation ourselves.
|
|
DC
|
|
devam
Groupie Joined: 20 March 2008 Location: India Status: Offline Points: 15 |
Post Options
Thanks(0)
|
Hi Oleg,
One more doubt. In your reply, you mentioned that we need to create our own DDX_Text for such an edit. But DDX_Text is not used for validation purposes, it is used to bind the control to a member variable. Did you mean that we implement our own DDV_MaxMinFloat?
How can we write our own DDX_Text to match our requirement of validating a string beginning with digits?
|
|
DC
|
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
Hi, DDX_Text in 2005 parse "12Hello" as 12 so its reason that DDV_MaxMinFloat validate value right.
So most easy way is to copy DDX_Text for float value from VC6 to your code and rename it to DDX_TextFloat.
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |