When you use cedit in MFC, you can only enter numbers, but the following error still occurs: "0 before number 200.
This situation is considered unfriendly to the user interface and needs to be achieved: if a non-zero integer 200 has been input, 0 is not allowed at 200, for example.
You can achieve this by using the following methods:
1. Control ing Integer Variables for cedit in the dodataexchange function:
Ddx_text (PDX, idc_edit_rxdelay, m_nrxdelay );
2. Add the on_en_update event to the begin_message_map..end_message_map message ing:
Begin_message_map (camc3020dlg, cdialog )...... On_en_update (idc_edit_rxdelay, & camc3020dlg: onenupdatenumedit )...... End_message_map ()
3. Add two lines of code to the onenupdatenumedit function:
Void camc3020dlg: onenupdatenumedit () {updatedata (1); // write the number entered in the cedit control to the corresponding integer variable. Here it is m_nrxdelay updatedata (0 ); // write the value in the m_nrxdelay variable back to the cedit control./* The two lines of code can remove the excess 0 above 200 */}
When only a number is input in MFC cedit, how can we prevent it from entering a non-zero integer starting with 0