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.
killaz4lifeAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
AndyAinscowConnect With a Mentor Freelance 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
 
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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
killaz4lifeAuthor Commented:
access, the array.
But I need some code written, other wise i wouldnt have asked the question
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.