Your example is wrong: Your
m_strString
variable is of type
CEdit
but it is used as
CString
.
You should read about
Dialog Data Exchange[
^] (DDX).
If you don't want to use DDX, add member variables of your control types and call the appropiate functions to set and get the values from within
OnInitDialog
(
SetWindowText
for
CEdit
) and
OnOK
(
GetWindowText
for
CEdit
).
See the MSDN for
OnInitDialog[
^] about the return value:
Quote:
Specifies whether the application has set the input focus to one of the controls in the dialog box. If OnInitDialog returns nonzero, Windows sets the input focus to the default location, the first control in the dialog box. The application can return 0 only if it has explicitly set the input focus to one of the controls in the dialog box.
[UPDATE]
The default implementation of
OnInitDialog
will call
UpdateData(FALSE)
. So you don't have to call it yourself when initializing your control member variables before calling the base class function
CDialog::OnInitDialog
(which is missing in your example).