How to communicate date from a Child Form to a Parent Form in Delphi 7
Posted on 2009-06-30
When I was programming in Visual C++ I would sometimes use very bad techniques to move data from a child dialog box to the window that calls it. Let's suppose I have a dialog box that shows a list of items in a single column grid. When the user double clicks on an item, that item is selected and the dialog box closes, returning control to the parent window.
In C++ I could get text from an edit field with a command like this:
In this case the variable answer_string would be a global variable so the user's selection would be available, through the global variable, to the parent window that called the dialog box.
I realize it is considered bad programming to have too many global variables. What is the proper way to transfer data in this situation? After double-clicking my dialog box shuts down so the user's answer has to be stored somewhere before the dialog box's memory is freed.
How do I cleanly shut down the dialog box? In C++, I could use this command:
What is the proper way to do this in Delphi?