1

I'm very new to MFC and dialog boxes. I am attempting to follow a very simple YouTube tutorial: "VC++/C++ MFC tutorial 1: Creating a Dialog box for user input"

The video, and many other sources seem to have CString as a variable type for the edit control however I only have primitive types (see attached image).

Currently running VS2017

I have attempted to reconfigure some of project settings by creating a new project. however, I am just turning knobs blindly at this point.

image

Available Types on my version.

image

Shows the type (CString) that I was hoping to have.

Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164
JCoder
  • 75
  • 5

1 Answers1

2
  • When you right-click the actual class itself to add a variable it only shows a generic list of variable types. However, as you can see, you are not limited to the values in the drop-down list. You can also type in a value, like CString. This is the same in VS 2019:

Add Variable

Add Variable

  • When you right-click a control on a dialog, the IDE knows what type of variables it will usually map to. So if you right-click a EDIT control, and choose to map it to a value instead of a control, it defaults to CString.

Add Variable

Add Variable


This is documented on the Microsoft website:

  • If you're adding a member variable that isn't a dialog box control, select from the list of available types. For information about the types, see Fundamental Types.

  • If you're adding a member variable for a dialog box control, this box is filled with the type of object that is returned for a control or value. If you select Control, then Variable type specifies the base class of the control you select in the Control ID box. If the dialog box control can hold a value, and if you select Value, then Variable type specifies the appropriate type for the value that control can hold. For more information, see dialog box controls and variable types.

Community
  • 1
  • 1
Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164