Solved

sharing variables

Posted on 2000-04-13
10
149 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
 
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

744 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

13 Experts available now in Live!

Get 1:1 Help Now