Controls versus Values
When mapping variables to controls in a dialog, there are two choices:
Controls and Values.
-
Control Variables
-
Control variables act like pointers to the actual dialog control:
whatever changes are made to the control variable will actually change
the dialog control. Use a control variable when changing the appearance
of the dialog control. They act like pointers, but they are accessed like
normal objects: use the dot, not the arrow, to reference a member. Because
they are pointers to the dialog controls, they only are valid when the dialog
is open.
-
Value Variables
-
Value variables are completely separate from the dialog controls.
In order to transfer data to and from the value variable, the method
UpdateData
must be used. Use value variables to store
user input. The advantages of value variables are
-
They will retain their values even when the dialog is closed.
-
They have automatic type conversion: if the value is a double, then the user
input will be automatically cast to a double.
It is possible to map a control and a value variable to the same dialog control.
This way, the appearance of the dialog controls can be changed easily, and
the input from the user can be remembered easily.