In MFC, for the typical dialog window, when OnOK() is called by MFC, this function calls the EndDialog() function, and somehow the class destructor is called at some point.
Suppose I have a public variable, a string named "test", in the CDialog's class, and in the dialog OK button's onBnClick() event, I set this "test" variable to a value. Then I declare an instance of the dialog, and call DoModal() from my main window's class. I can read from the variable that was set once DoModal() returns, no problem.
void Dialog1::OnBnClickedOk()
{
test = "The test string has been set.";
OnOK();
}
void CMainFrame::OnEditTest()
{
Dialog1 dlg;
dlg.DoModal();
MessageBox(dlg.test, L"Main Frm",0);
}
This works, but what if I have a dialog with several fields, and a variable for each field. How can I be sure that I can read all of the values from all the variables before the destructor is called? I checked MSDN, and my understanding is that the OnOK() function calls EndDialog(), and at some point, after EndDialog(), the class destructor is called. I want to always be able to read the values from the variables that were set from the OnBnClick() event, but I don't know exactly when MFC calls the class destructor. Does anyone know when the destructor is called once EndDialog() fires?
Thanks, Blitz