Solved

sharing variables

Posted on 2000-04-13
10
151 Views
Last Modified: 2013-11-20
my application contains a view in which an editbox and a command button is placed. on clicking the command button  a dialog box opens . now i want to access the contents of the edit box in  the view from the dialog box . how do i do that?
0
Comment
Question by:karthik1979
  • 5
  • 4
10 Comments
 
LVL 10

Expert Comment

by:RONSLOW
ID: 2712184
You can explicitly pass the view object to the dialog, or you can get at the view because it is the parent of the dialog.

Either way, once you get the view, you can then get at the data in it (either member data or directly at the control).
0
 

Author Comment

by:karthik1979
ID: 2712977
please explain me in detail as i am new to VC++ real world programming
0
 
LVL 32

Expert Comment

by:jhance
ID: 2713307
Well, the first thing you should do is add some points to this question.
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 10

Expert Comment

by:RONSLOW
ID: 2714212
hehehe .. 2 points ain't really enough for details of how to implement.

but here is a bit more info...

if your view is CMyView and your dialog CMyDialog then you can put a CMyView* m_pMyView public member in your CMyDialog class, and then, in the function in CMyView that starts the dialog do something like this

  CMyDialog dlg;
  dlg.m_pMyView = this;
  if (IDOK == dlg.DoModal()) ...

then, from within your CMyDialog, you can get at info in the view via m_pMyView->m_xxxxx etc.

Thats more than enough info for 2 points.
0
 

Author Comment

by:karthik1979
ID: 2714436
Adjusted points from 2 to 10
0
 

Author Comment

by:karthik1979
ID: 2714437
I got half the way ronslow said i am getting an error as  'operator = function is not available' i could do nothing than increasing the points to 10
please reply me immeditely
0
 
LVL 10

Accepted Solution

by:
RONSLOW earned 10 total points
ID: 2714492
Then you've done something wrong.  Show me the code as it is so far.

And don't keep rejecting .. if you are working on an answer with an expert, you are supposed to keep the question locked, and exchange comments, not keep rejecting all the time.

NOTE: generally even 10 points is not really enough for this sort of write-the-code-for-you and work closely-with-you-question.  One would usually expect at least 50 points.

0
 

Author Comment

by:karthik1979
ID: 2714535
Hi ronslow,
i got it in another way.
 i declared a variable abc in dialog
and from my view i wrote the code

CMydialog a;
m_edit1.SetWindowText(a.abc)
a.DoModal(); is working fine. but any way please say to me how to make the view pointer available to the dialog class  
0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 2714579
What you've done is the other way around .. you've copied the (empty) text from the dialog into the view.

If you do indeed want to copy from dialog to viwe (the opposite to what you asked) then move the m_edit1... line to AFTER the a.DoModal, so you will copy the abc value of the dialog to the edit box.

If you want to copy the edit box data to the dialog, then do this

  CMyDialog a;
  m_edit1.GetWindowText(a.abc);
  a.DoModal();

and if you want to copy it back afterward, add
  m_edit.SetWindowText(a.abc)
after the DoModal call.

I've already told you how to get at the view class from within the dialog .. I don't think that you can justify asking for more deatils with a mere 10pts .. if you look at the Ask A Question page, it suggests 50 points for an easy question, 100 for moderate etc.  If you expect an expert to go into more details, I'd offer a reasonable amount of points.

0
 

Author Comment

by:karthik1979
ID: 2716944
Thanks Mr. RONSLOW
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MFC Dialog 9 49
has22 challenge 11 92
Modbus - whats the maximum I can store in one register? 4 79
firstChar challenge 13 114
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

813 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

19 Experts available now in Live!

Get 1:1 Help Now