When only a number is input in MFC cedit, how can we prevent it from entering a non-zero integer starting with 0

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.