1

After working in C# for years, I've returned to an old MFC application I wrote. But it looks like I need a refresher on a few things.

I added a check box control to an existing dialog box. I then used Class Wizard to add a non-control variable of type bool. The variable was created as expected.

However, I see no entry was added to the DoDataExchange() method. And when I tried adding it manually:

DDX_Check(pDX, IDC_PRINT_SUMMARY, m_bPrintSummary);

I get the IntelliSense error:

a reference of type "int &" (not const-qualified) cannot be initialized with a value of type "bool"

1. Why wasn't an entry in DoDataExchange() created for me when I added the variable?

2. If DDX_Check() expects and int &, why did Class Wizards default to type bool for a checkbox value?

Jonathan Wood
  • 65,341
  • 71
  • 269
  • 466

1 Answers1

2

A check box can be one of three values, hence the need for the int.

BST_CHECKED - Button is checked.

BST_INDETERMINATE - Button is grayed, indicating an indeterminate state (applies only if the button has the BS_3STATE or BS_AUTO3STATE style).

BST_UNCHECKED - Button is cleared

As to why it's not auto editing the DoDataExchange, it's probably an issue with the C++ formatting of your class.

snowdude
  • 3,854
  • 1
  • 18
  • 27