Solved

sharing variables

Posted on 2000-04-13
10
152 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need a Shell script to start a service checking the port 6 53
cat dog challenge 18 127
Doc'in system (example?) BA 7 116
Problem to open Excel file 15 179
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

820 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