Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > General Discussion
  New Posts New Posts RSS Feed - MFC DDV_MinMaxFloat does not work
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

MFC DDV_MinMaxFloat does not work

 Post Reply Post Reply
Author
Message
devam View Drop Down
Groupie
Groupie
Avatar

Joined: 20 March 2008
Location: India
Status: Offline
Points: 15
Post Options Post Options   Thanks (0) Thanks(0)   Quote devam Quote  Post ReplyReply Direct Link To This Post Topic: MFC DDV_MinMaxFloat does not work
    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. 
  
 Note:  
 1. This code is written in Microsoft Visual Studio 2005
 2. If the same code is written in MS VC6 then MFC framework automatcally handles all scenarios and it working fine.

DC
Back to Top
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 Posted: 02 March 2009 at 7:37am
Hi,
guess you need create own DDX_Text for such edit. See original one and change it.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
devam View Drop Down
Groupie
Groupie
Avatar

Joined: 20 March 2008
Location: India
Status: Offline
Points: 15
Post Options Post Options   Thanks (0) Thanks(0)   Quote devam Quote  Post ReplyReply Direct Link To This Post Posted: 02 March 2009 at 7:46am
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
Back to Top
devam View Drop Down
Groupie
Groupie
Avatar

Joined: 20 March 2008
Location: India
Status: Offline
Points: 15
Post Options Post Options   Thanks (0) Thanks(0)   Quote devam Quote  Post ReplyReply Direct Link To This Post Posted: 03 March 2009 at 12:03am
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
Back to Top
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 Posted: 03 March 2009 at 12:59am

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
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.171 seconds.