Notify child window of event in parent window.

Posted by Freddy Boisseau on 31-Oct-2008 10:44

I think I saw a thread on this, but I can not seem to find it right now. What I am trying to do is when a event happens in a parent window (ie.. a field value changes), I want to notify all the children window about that event and have them react to the new field value. Normally I would have the parent procedure publish an event and have the child subscribe to it, but the rules for publish and subscribe with classes seems to be different. So can anyone point me to the best way to handle this, keeping in mind that the child windows can be opened or closed by the user?

Thank you

All Replies

Posted by Freddy Boisseau on 31-Oct-2008 14:46

Okay, I have found out how to execute methods in child windows, when a event in the parent was triggered. The code was basically in the close window method of the standard mdi window. Now the second half of my question. How can I determine if a child window is already open? I want to know this because I only want to open one copy of each window. Thank you.

Posted by Peter Judge on 31-Oct-2008 14:52

Okay, I have found out how to execute methods in

child windows, when a event in the parent was

triggered. The code was basically in the close

window method of the standard mdi window. Now the

second half of my question. How can I determine if a

child window is already open? I want to know this

because I only want to open one copy of each window.

Thank you.

You can check/traverse the MDI parent form's MdiChildren property to see all of the MDI children, or you can use something like a temp-table and check whether a child form has already been invoked.

AutoEdge uses the latter approach. If you do this, remember to clean up when the child form is closed (take a look in gui/autoedge/mainviewaui.p for both of these).

-- peter

Posted by Freddy Boisseau on 31-Oct-2008 15:19

Where can I find gui/autoedge/mainviewaui.p?

Message was edited by:

Frederic Boisseau

Posted by Freddy Boisseau on 31-Oct-2008 15:28

Never mind I found it.

Posted by Peter Judge on 31-Oct-2008 15:29

AutoEdge is available here http://www.psdn.com/library/entry.jspa?externalID=5742&categoryID=2064 . You'll need to install it to look at the source code.

-- peter

Posted by Admin on 01-Nov-2008 03:54

Isn't there a more elegant way of communicating between windows than placing code in the close window method. Publish and Subscribe was pretty powerful and very elegant. Don't we have equivalent in OO approach ?

This thread is closed