Solved

data sharing between dialog boxes

Posted on 1998-08-13
4
201 Views
Last Modified: 2013-11-20
I have several dialog boxes in my project and I need to take amounts from one screen to another, will someone please tell me how to share the data between them. I have already create variables for the edit boxes which I am trying to share data between. The data I am trying to get is in CService2Dialog and I am trying to place it in CServiceDialog.  The variables are m_billtime(CServiceDialog) & and want it to come from m_totlab(CService2Dialog). These variables are double. When the user hits the "Calculate" button on page 1 the amount should appear in the corresponding edit box.  If this can be done without hitting the button it does not matter but I figured it might be easier. Please tell me exactly where to put the statements because I do not understand Visual C++ 5.0 completley at this point.
Also if it is not to much trouble show me how to get zeros at the end of the number.  eg. if the data is 1, I want it to show 1.00(dollar figures).

Thank You for the much need help!      
I apologize for enter this question the second time but the first answer didn't work because I am only new to programming in Visual C++ 5.0 and I could not figure it out after hours of struggling.

//This is the Calculate button on page 1.  
void CServiceDialog::OnCalcButton()
{
      // TODO: Add your control notification handler code here
      
      UpdateData(TRUE); // get data from controls
          
      //Here is where I want to recieve data from page 2 and place it here to calculate the data on page 1.
      //output the new data recieved.
      cout<<m_billtime;
      
      //ignore this it is only other calculations.
      m_tottravel.Format("%.2f", atof(m_billtravel)*atof(m_ratetravel));  //calculate total labour
      m_totlabour.Format("%.2f", atof(m_billtime)*atof(m_ratelabour));
      m_totinv.Format("%.2f", atof(m_totparts)+atof(m_tottravel)+atof(m_totlabour)); //calc total invoice
         
       UpdateData(FALSE); // send data to controls

}

0
Comment
Question by:troy11
  • 2
4 Comments
 
LVL 8

Accepted Solution

by:
trestan earned 100 total points
Comment Utility
There are several ways available to do it.
The first, you can save your data in a data file using fstream of CFile. Then read the data from this file in another dialog.
The second, I think you create the dialogs in your view, right? So you can exchange data between each dialogs' data memebers. E.g. ServiceDialog.m_billtime = Service2Dialog.m_totlab, where the ServiceDialog and Service2Dialog are the instances of the corresponding classes in your View. Pls contact with me if any futher questions.

0
 
LVL 1

Expert Comment

by:arun_ta
Comment Utility
In the class given n ur Qn, add a member variable which is a pointer to CServiec1Dialog (or any other required dlg). Using that pointer, u can do an UpdateData(TRUE) on it and then get value.

ie,
 
void CServiceDialog::OnCalcButton()
{
   UpdateData(TRUE); // get data from controls

   //a pointer to CService1Dlg is to be declared in    
   //CServiceDialog...
   
   pCService1Dlg->UpdateData(TRUE); //prepare to get data from            
                                    //other dlg
   cout<<(pCServiceDlg->m_billtime);  
   ....   
  // similarly to send data to controls...
}
 

0
 

Author Comment

by:troy11
Comment Utility
When I place this code in my calculate button

CServiceDialog.m_billtime = CService2Dialog.m_totlab;


it gives me these error messages

C:\visualc++5\menu\ServiceDialog.cpp(87) : error C2143: syntax error : missing ';' before '.'
C:\visualc++5\menu\ServiceDialog.cpp(87) : error C2143: syntax error : missing ';' before '.'

can anyone help me?



what do you mean by - n ur Qn-

0
 

Author Comment

by:troy11
Comment Utility
This code is in calculate button and I am trying to access data from CService2Dialog and place it in CServiceDialog.  Ther is an Exit button and a Page 1 button on page 2 (CService2Dialog).  The exit uses OnOK() and the page 1 use DoModal. Is this causing me a problem when I try to access my data on page 1 because I have to press either to get to page 1 or is it the cout<<m_billtime

void CServiceDialog::OnCalcButton()
{
      // TODO: Add your control notification handler code here
      UpdateData(TRUE); // get data from controls
      
      CService2Dialog m_SrvDlg2;
      CServiceDialog m_SrvDlg;
      m_SrvDlg.m_billtime = m_SrvDlg2.m_totlab;
 
      cout<<m_billtime;
...      
}
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Error on moodle after upgrade 3 105
Looking for a specific application/software 2 91
WinWaitActive parameters 12 31
MaxSpan challenge 9 65
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…
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.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

772 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

11 Experts available now in Live!

Get 1:1 Help Now