먼저 선언되어 있지 않은 OnIntitDialog 를 재정의 통해서 추가한다.

자식창 코드
BOOL CNewDialog::OnInitDialog()
{
 CDialog::OnInitDialog();

 // TODO:  여기에 추가 초기화 작업을 추가합니다.

// 부모창의 포인터를 얻어서 GetValue 라는 사용자 정의 함수를 호출한다.
 CString m_str;
 CModalDlg *pMainWnd = (CModalDlg *)AfxGetMainWnd();
 m_str = pMainWnd->GetValue();
 TRACE(L"GET = %s\n", m_str);
 CEdit *pEdit = (CEdit *)GetDlgItem(IDC_EDIT1);
 pEdit->SetWindowTextW(m_str);

 return TRUE;  // return TRUE unless you set the focus to a control
 // 예외: OCX 속성 페이지는 FALSE를 반환해야 합니다.
}


부모창 코드.
CString CModalDlg::GetValue(void)
{
 CString m_str;
 CEdit *pEdit = (CEdit *)GetDlgItem(IDC_EDIT1);
 pEdit->GetWindowTextW(m_str);
 TRACE("GetValue = %s \n", m_str);
 return m_str;
}

Posted by +깡통+