Solved

sharing variables

Posted on 2000-04-13
10
155 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
[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
  • 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
Industry Leaders: 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!

 
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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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 this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

626 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