I have a main window which contains two CListCtrl controls and a button when pressed opens a new Dialog window in which the user can type or enter into a CEdit control. However what I want to do is to save the data contained in the CEdit control into one of the two CListCtrl. What I did was created the new dialog window using DoModal but when the function returns I try accessing the value contained in the CEdit control but nothing gets returned. I can only retrieve the value within the CEdit control in a OnOK handler of the new window.

Here is a sample code:

CUserInfo dlg;
int nResponse = dlg.DoModal();

if(nResponse == IDOK)
{
// Cannot get the values of the text field in the CEdit control here but only in the OK button handler of this new window.

// But I want to be able to get the values here in this function.
}