tags:

views:

15

answers:

2

I am using MFC, to develop a Mobile App. For one of the CEdit controls, in the dialog box, I declared a variable as long int as follows.

DDV_MinMaxUInt(pDX, m_txtCurrentValue, 1, 2000);

So whenever, I try to close the dialog box with invalid values (integers that is not in the range specified or which are alphabetic characters.) it throws a message and focuses that particular control.( Done automatically)

Now my question is that, I have a button and when ever this button is clicked, how can the same validation, functionality be called?

+1  A: 

You can call these routines yourself. I did this many years ago.

This link may help:

http://msdn.microsoft.com/en-us/library/57weza95%28v=VS.80%29.aspx

Jeff
A: 

Something like this:

// ...
DDX_Text(pDX, IDC_MY_EDIT, m_MyValue);

if (m_MyValue > 100)
{
    AfxMessageBox(_T("blablabla");
    pDX->Fail(); // throws an exception, aborts the data exchange
}
valdo