[RESOLVED] display data from edit control to view
hello
my problem is i have created a SDI application.
i have a dialog in it .which contains OK and CANCEL buttons. it also contains an Edit control.
i have to get data from the edit control and display it to view.
the steps that i have done r
created a menu which has (Dialog->ModalDlg[item])
Code:
void CModalTestView::OnDialogModalDlg()
{
CTestDlg dlg;
dlg.DoModal();
//CEdit* edName=(CEdit*)GetDlgItemText(IDC_EDIT_NAME,dlg.m_strNAME);
//CString m_strNAME
int nRet = dlg.DoModal();
if(nRet == IDOK)
{
AfxMessageBox(dlg.m_strNAME);
}
}
Code:
void CMyDialog::OnOK() //CMyDialog is dialog box class derived from CDialog
{
GetDlgItemText(IDC_NAME,m_strName1);
CClientDC dc(this);
dc.TextOut(110,100,m_strName,m_strName.GetLength());
//CDialog::OnOK();
}
this is what i have written plz correct this.or plz give me suggestions
my problem is to get text from editcontrol and display it to view when i click OK button.
Re: display data from edit control to view
1. Make the m_strName the (CString) member variable of the IDC_NAME edit control. After that you could remove all your code from CMyDialog::OnOK() (CDialog::OnOK(); call must be uncommented or just remove the overriden OnOK() method)
2.
Code:
void CModalTestView::OnDialogModalDlg()
{
CTestDlg dlg;
dlg.DoModal();
int nRet = dlg.DoModal();
if(nRet == IDOK)
{
AfxMessageBox(dlg.m_strNAME);
// and now display dlg.m_strNAME somewhere in the View
// Where and How should it do it depends on what View are you using...
....
}
}
Re: display data from edit control to view