Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 263
  • 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
 
AndyAinscowCommented:
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
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.

 
AndyAinscowCommented:
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
 
AndyAinscowCommented:
<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
 
AndyAinscowCommented:
split
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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