CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2009
    Posts
    128

    [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.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    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...
    		....
    	}
    
         }
    Victor Nijegorodov

  3. #3
    Join Date
    Nov 2009
    Posts
    128

    Re: display data from edit control to view

    i got it .thanks sir

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured