Solved

Sending array to another dialog class

Posted on 2006-06-14
11
257 Views
Last Modified: 2013-11-20
How can I send a 2dimensional array lets say 2Darray from the main dialog class, to the other dialog class.
0
Comment
Question by:killaz4life
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
11 Comments
 
LVL 12

Expert Comment

by:rajeev_devin
ID: 16908782
Send the array via constructor to other dialog classes.
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 16909630
Do you require a copy or just access to one array?
0
 

Author Comment

by:killaz4life
ID: 16911100
access, the array.
But I need some code written, other wise i wouldnt have asked the question
0
 Database Backup and Recovery Best Practices

Join Percona’s, Architect, Manjot Singh as he presents Database Backup and Recovery Best Practices (with a Focus on MySQL) on Thursday, July 27, 2017 at 11:00 am PDT / 2:00 pm EDT (UTC-7). In the case of a failure, do you know how long it will take to restore your database?

 
LVL 44

Accepted Solution

by:
AndyAinscow earned 125 total points
ID: 16911276
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
 

Author Comment

by:killaz4life
ID: 16966443
are u geussing any rubish or do you know wut a 2darray is?
here
int histo[r][c];

do u understand now?
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 16966627
<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
 
LVL 7

Expert Comment

by:nafis_devlpr
ID: 17080545
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
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 17294139
split
0

Featured Post

Enroll in July's Course of the Month

July's Course of the Month is now available! Enroll to learn HTML5 and prepare for certification. It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question