I have written an app with a main window and a dialog window. I would
like to be able to have an event from the dialog window update some
information in the main window. So, Visual Studio creates two .h files
with two classes for each of the Forms (Main Window and Dialog Window).
The way I have written the application right now is to add an event
handle to the Main Window so that when a button is pressed it opens the
Dialog Window. This works fine and I am able to pass data from the
Main Window to the Dialog Window with no problem as such:
/* snip from MainWindow.h */
DialogWindow *show_dialog= new DialogWindow();
show_dialog->textBox1->Text = S"new text";
show_dialog->ShowDialog();
/* end snip */
My problem is that I would like to go the other way as well:
/* snip from DialogWindow.h */
MainWindow->textBox1->Text = this->textBox1-Text;
/* end snip */
Obviously this code will not work since DialogWindow knows nothing
about MainWindow. I have found the Form::Owner method and it looks
close to what I want since I can use it to create a handle in
DialogWindow that points to its owner MainWindow (I still cant
reference textBox1). I think that I will need a third class that
creates and shows both dialogs. The problem is that I cant include the
header for my dialogs (They are not just declarations they are also the
class definitions) in my third class while also including the header
file from my third class in my dialogs (I hope that makes sense).
I am hoping that someone can provide some ideas or reference some
example/tutorials that I have not been able to find via Google (I have
become even better friends with google over this issue) or msdn.
I hope I have made myself clear enough for someone to provide some
pointers. If not I will be happy to clarify as much as I can.
Thanks for any help you can provide.
Jason
jason.a.malone@gmail.com - 10 Mar 2005 14:33 GMT
Can this not be done? I mean, it is basically the same thing as a
FileOpenDialog. I just want to use a custom dialog instead of the
canned one. The FileOpenDialog can be included in the form (the same
header file) Is it possible to make a custom dialog into a component
that can be included the same way?