• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 266
  • Last Modified:

Sending array to another dialog class

How can I send a 2dimensional array lets say 2Darray from the main dialog class, to the other dialog class.
0
killaz4life
Asked:
killaz4life
1 Solution
 
rajeev_devinCommented:
Send the array via constructor to other dialog classes.
0
 
AndyAinscowFreelance programmer / ConsultantCommented:
Do you require a copy or just access to one array?
0
 
killaz4lifeAuthor Commented:
access, the array.
But I need some code written, other wise i wouldnt have asked the question
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
AndyAinscowFreelance programmer / ConsultantCommented:
class CDlg1 : CDialog
{
public:
  2Darray m_arTwoD;   //public member of the dialog
...


somewhere in the .cpp file

void CDlg1::ShowDlg2()
{
  CDlg2 dlg(this);
  dlg.DoModal();
}


and in the code for dlg2

CDlg1* pDlg1 = (CDlg1*)GetParent();
pDlg1->m_arTwoD   //this is a pointer to the array in the other dialog.
0
 
killaz4lifeAuthor Commented:
are u geussing any rubish or do you know wut a 2darray is?
here
int histo[r][c];

do u understand now?
0
 
AndyAinscowFreelance programmer / ConsultantCommented:
<are u geussing any rubish or do you know wut a 2darray is?>
YES, I have coded something working in 250 dimensional space some years ago, so I do have some knowledge of maths.

Do you understand my psuedo-code showing you how to do what you requested?
0
 
nafis_devlprCommented:
Take a look at the following code:

//somewhere in the main dialog class
//assuming histo[r][c] as the 2darray and CMainDlg as the main Dialog class
YourDialog dlg(this);


class YourDialog : public CDialog
{
public://or private
  CDialog *ptr;
...
}
//Constructor of the YourDialog class

YourDialog(CDialog* ptr)
{
      this->ptr=ptr;
}

or You can do the same thing using a function in YourDialog Class

YourDialog::SetDialog(CDialog* ptr)
{
      this->ptr=ptr;
}

in that case you will have to set it this way
//somewhere in the main dialog class
YourDialog dlg();
//some code....
dlg.SetDialog(this);

after that
//somewhere in the YourDialog class
int k=(CMainDlg*)ptr->histo[0][0];

just use it as a normal 2d array
0
 
AndyAinscowFreelance programmer / ConsultantCommented:
split
0

Featured Post

2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

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