Multiple Windows W/Logically Attached Children

Hi Folks,

I’m working on a new tool that will allow multiple instances of itself via a “File” -> “New Task” menu item. When a new task is started, a new instance of the main window is opened and once the task is defined, a new process monitor window is opened with the parent task window being hidden. The app could support up to 10 simultaneous instances, and therefore have 10 logical children assigned for the tasks. I need the child windows to be able to communicate back to its parent window to unhide and update the summary fields when the task completes.

Another project that opens multiple children from a single main window is easy to deal with since they all feed back into the main.

Ideas? An Array of Windows? An array of classes that track the Windows? Just scratching my head on this on logically.

Perhaps something similar to this?

http://www.realsoftwareblog.com/2013/03/observer-pattern.html

So you have up to 10 pairs of

MainWindow <—> ProcessMonitorWindow

At any given time, only one of the pair is active/visible. It seems like ProcessMonitorWindow simply needs a reference to its MainWindow. It doesn’t need to know about any other windows. I think a simple reference, ParentWindow as MainWindow, would be sufficient.

[quote=269670:@Tim Hare]So you have up to 10 pairs of

MainWindow <—> ProcessMonitorWindow

At any given time, only one of the pair is active/visible. It seems like ProcessMonitorWindow simply needs a reference to its MainWindow. It doesn’t need to know about any other windows. I think a simple reference, ParentWindow as MainWindow, would be sufficient.[/quote]
Funny, I’d just worked up a simple test using this type of thing. I instantiate the task progress window, assign its taskParentWindow to the calling parent’s Self, open the task window, and then start a timer on the task window to hide the assigned parent.

This seems to be the easiest solution to this scenario.

[quote=269668:@Anthony Dellos]Perhaps something similar to this?

http://www.realsoftwareblog.com/2013/03/observer-pattern.html[/quote]
Thanks, Anthony, but that’s more the opposite of what I’m looking for and what I already use for my one to many configurations.

You’re welcome.

Just skimmed your post and wasn’t sure “which way you were going”. Thought that might be backwards/opposite, but had it bookmarked, so why not share? :wink:

Revisiting @Tim Hare -

I’ve got the parent and child windows sorted
Implicit is off
On startup (App.Open), I init and open a wTaskMain window
The user sets options and starts the task
The start action inits a taskProgress window but doesn’t show it
The next item after creating the New taskProgress window is to set the taskProgress.myParentWindow property to Self
The taskProgress window is shown and the task runs
The task completes and tries to communicate with myParentWindow
I get a NOE that the taskProgress.myParentWindow is NIL

When I debug and check the taskProgress Window properties, the myParentWindow IS NILL.

Here’s my code to init and show the taskProgress window:

  wTaskProgress = New wIngestOperationProgress
  wTaskProgress.myParentWindow = Self
  wTaskProgress.Show
  Self.Hide

Also, the parent wTaskMain window does not hide…

Any ideas?

I just realized something else -

Even though I have the taskProgress window marked as non-implicit, it is still opening as soon as I issue the New call:

  wTaskProgress = New wIngestOperationProgress

This could definitely be messing things up since the following three commands are not run until after the progress tries to close the TaskProgress window.

Is that normal?

What does the open event on wIngestOperationProgress do ?
Are there open events on controls on that window that might be forcing the window to show ?

[quote=269825:@Tim Jones] wTaskProgress = New wIngestOperationProgress
wTaskProgress.myParentWindow = Self[/quote]
Why not

wTaskProgress = New wIngestOperationProgress( self )

[quote=269832:@Norman Palardy]Why not

wTaskProgress = New wIngestOperationProgress( self )[/quote]
Ummmm, that’s one that I’ve obviously missed over the years! :S

Aha - more Constructor magic.

  Constructor(theParent As wMain)

    myParentWindow = theParent
    ...

Is the window modal?

Nope - but it does do setup in the Constructor and insures positioning and frontmost in Open.

Norman’s note about passing Self to the window and setting the local property in the Constructor has sorted this out properly.