Conversion of BOOL and bool Note: True is not necessarily 1, such bool will cause the value of the control checkbox to zero

Source: Internet
Author: User

A bool value from a configuration file, network, or other means, when assigned to bool, the discovery of true is not necessarily 1

There may be other errors causing this value to be wrong. Although it does not affect logic, it still shows that there are errors in other areas of logic.

To make a judgment, do not let values other than 0 and 1 enter bool,

Otherwise, the value of the control checkbox is returned to zero

The MFC code is as follows:

void Afxapi Ddx_check (cdataexchange* pDX, int nIDC, int& value) {... if (Value < 0 | | | value > 2) {TRACE (traceap PMSG, 0, "Warning:dialog data checkbox value (%d) out of range./n", value); Value = 0; Default to Off} ...}

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.