When an int variable is added to the edit box, the following two values can be set to the maximum and minimum values;
Or add it by yourselfCodeDdv_minmaxint (PDX, m_nport, 1, 65535 );
But this does not have to work.
Solution: Add a message with no focus (killfocus) to the edit box, and set updatedata (true) in it.
The reason is that when the focus is lost, synchronize the values of the form and related variables so that the subsystem can correctly determine whether the value exceeds the set range.
However, there is another reason, as long as your input value is not in the Set range, then your focus cannot leave the control, because it will always pop up.
Solution: Remove ddv_minmaxint (PDX, m_nport, 1, 65535) and write the code in the killfocus function to determine the cause.
{
Updatedata (true );
If(M <0) | (M>65535))
{
Messageboxw (null, l"The value range is exceeded!", L"Error", Mb_ OK );
M =0;
Updatedata (false );
}
}
Note: In fact, this is no different from the first one, but it is more flexible.The cstring type variable can be used to set the string length..
Supplement: After Techwalker reminder,ProgramThe user may not lose the focus of the edit box after the input, but directly press the Enter key to go to the next step, so what is mentioned above will cause problems. So I searched and should useEn_changeMessage insteadKillfocusMessage.
{
// Todo: if this is a RichEdit control, the control will not
// Send this notification unless you override the cdialog: oninitdialog ()
// Function and call cricheditctrl (). seteventmask ()
// With the enm_change flag ored into the mask.
// Todo: add your control notification handler code here
Updatedata (true );
If (M_neditnum>100 ) | (M_neditnum < 1 ))
{
M_neditnum = 1 ;
Updatedata (false );
}
}
For more information, see: cedit class (edit class) member function and message http://hi.baidu.com/chaohona/blog/item/0d1d8f597486608b800a1880.html
[Thank you for your reference]
How in the text box input MFC can get data: http://zhidao.baidu.com/question/308978825.html? Fr = qrl & cid = 93 & Index = 5
Edit box cedit wrap simple settings: http://www.cnblogs.com/ziwuge/archive/2011/12/03/2274886.html