Solved

Sending array to another dialog class

Posted on 2006-06-14
11
250 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
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
 
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now