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

x
?
Solved

sharing variables

Posted on 2000-04-13
10
Medium Priority
?
159 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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 30 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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 …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Screencast - Getting to Know the Pipeline
Suggested Courses

782 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