1

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?

RK-
  • 12,099
  • 23
  • 89
  • 155

2 Answers2

1

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
  • 1,969
  • 3
  • 21
  • 35
0

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
  • 12,632
  • 2
  • 37
  • 67