Solved

How to exchange data between forms?

Posted on 2001-08-23
8
245 Views
Last Modified: 2008-02-01
C++ Builder 5.0: Building MDI Application.I have first form named Form1 and there I want to input some data (long double Number1, Number2, Number(...);). Then I want to use this numbers to calculate something but on the ChildForm or on the new forms named Form2, Form3, Form(...).
How to do that? (Maybe it can be usefull to create some little aplication with comments in code, compress it with WinRAR or WinZIP and send it to me).
                      Thank You.
0
Comment
Question by:Peca
8 Comments
 
LVL 6

Expert Comment

by:DrDelphi
ID: 6419631
Why don't you just make the data Public? This way,any other form (or unit) would be able to read it.

0
 
LVL 6

Expert Comment

by:Triskelion
ID: 6419944
How much data?
Can you make global variables?




global variables
0
 
LVL 14

Accepted Solution

by:
AlexVirochovsky earned 50 total points
ID: 6420900
I assume you are using an MDI parent as your main window. If this is true, use

Application->MainForm to access the MDI parent window.

to access this parent. The parent window can either know about each of the
shared data classes, or, you could iterate throught the ->MDIChildren[ ] to
find the form you are interested in.

Other ways:
a) Send messages with the data.
 Uses either Windows messages, Delphi messages or some more complex
messaging like DDE to pass data. Windows messages are sent with the
Windows API SendMessage and can include something like a pointer to more
complex data or simple 32 bit numeric data. Delphi messages are send the
same way, but have a different set of codes. DDE is a technology of its
own, and BCB provides components to work with it, but you'll have to
look them up.

b) Set up a shared proxy object containing the shared data.I recommend using a data module. The
data module does not need to contain any components - you just add
public properties backed with private variables, like:

private:

double FSharedFloat;

public:

__property double SharedFloat = {read=FSharedFloat,
write=FSharedFloat};

Obviously you could also expose the variable directly.

0
 
LVL 11

Expert Comment

by:griessh
ID: 6861940
I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. Unless there is objection or further activity,  I will suggest to accept "AlexVirchovski" comment(s) as an answer.

If you think your question was not answered at all, you can post a request in Community support (please include this link) to refund your points.
The link to the Community Support area is: http://www.experts-exchange.com/commspt

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:Peca
ID: 6863127
I resolve the problem.
0
 

Author Comment

by:Peca
ID: 6863129
I resolve the problem.
0
 
LVL 5

Expert Comment

by:Netminder
ID: 6884088
Peca,

If you will please post what you did to resolve the problem, I will refund your points to you and close this question.

Thanks,

Netminder
CS Moderator
0
 
LVL 5

Expert Comment

by:Netminder
ID: 6899770
User declined to explain how he resolved the issue. Force-accepted by
Netminder
CS Moderator
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

746 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