Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 246
  • Last Modified:

send varibale value to parent

how can i send the value of my Edit field from a dialog to parent dialog variable id_latlon
when pushing IDC_SEND  button.

what is the procedures and step needed to be taken for this
0
glenn007
Asked:
glenn007
  • 2
  • 2
1 Solution
 
williamcampbellCommented:
Two ways

Child Dialog gets apointer to the parent
or
Parent calls function in the Child Dialog

class CMyDialog :
{
  CString m_csData;
  CDialog m_pParent;
 
  SetParent ( CDialog* pParent ) { m_pParent = pParent; }

  OnSend ( ..   // IDC_SEND Button
  {
     myEdit.GetWindowText( csData );
     if ( m_pParent ) // Either do this directly
        m_pParent->id_latlon = csData; //better to have function
  }

   GetData () { return m_csData; }
};


  CParentDlg parentDlg;

  CMyDialog myDlg;
  myDlg->SetParent ( &parentDlg );
  myDlg.DoModal ();

  or

  CParentDlg parentDlg;

  CMyDialog myDlg;
  myDlg.DoModal ();

  parentDlg->id_latlon = myDlg->GetData ()

 
0
 
glenn007Author Commented:
cant figure out how to do it, could you help me more

my main dialog is created in this id

CScrollBitmapDlg::CScrollBitmapDlg
and the popup dialog is created in

CCalibrate::CCalibrate(CWnd* pParent /*=NULL*/)
     : CDialog(CCalibrate::IDD, pParent)

where should i insert the code to get it to work, i am having a hard time figuring out how. :(
0
 
glenn007Author Commented:
this is my OnSend

void CCalibrate::OnSend()
{
this is to execute to send data to parent dialog CScrollBitmapDlg::CScrollBitmapDlg
     
}
0
 
williamcampbellCommented:

  When CCalibrate is Created pass in the CScrollBitmapDlg as the parent... You see the parent is being set to NULL above.

  Send the code of the classes

  then in OnSend
 
  void CCalibrate::OnSend ()
  {
    ((CScrollBitmapDlg*)GetParent ())->id_latlon = data;
  }


 
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now