Manage the window chain

Hi
I’m on a Mac running OSX10.8 and Xojo 2013R2.
I have a dialog called saveChanges that can be called from any window with unsaved changes. It does the obvious - allows the user to save the changes, abort the close and close without saving.
I need to refine the window layout a little depending on what window is being closed. Under REAL Studio you could code
if window(1) isa …
The saveChanges dialog was always window(0) and it’s parent window(1). That’s no longer the case.
Is there a simple way of checking on the parent window in this type of situation? I know I could do something like dropping a reference into a global property and checking that but the REAL Studio approach was so much simpler and more elegant.

Using the debugger it looks like, in saveChanges Open event, it is window(1) and the parent window(0) … can I depend on that?

Any advice would be welcome.
Jack

Make your “save changes” screen a modal screen which returns a value then let the calling window handle the return process. No need for the modal scrn nor your code to care about which window called it. I have an example if you need it.

Thanks for the reply.
Return value from the “save changes” is not the problem. I do check the return from the dialog. My problem is that I need to know in the dialog’s open event who called it.

There’s nothing built-in, really, to help you. You can create your own method in the dialog called ShowMe and pass in the calling Window.

dim dlg as new SomeDialog dlg.showme(self)

Then in ShowMe you have something like:

Sub ShowMe(w as Window) self.parent = w self.show End Sub

You could also do this in the Constructor of the SomeDialog.

dim dlg as new SomeDialog(self)

This way if you have multiple windows that have have invoked the dialog you know which parent window called it. So if you wanted to update the parent window sou could put some code in like this:

if parent isa SomeWindow then SomeWindow(parent).SomeMethod end

“My problem is that I need to know in the dialog’s open event who called it.”
Why? I’ll bet if you think about it, you really don’t. Each window needs to respond differently to the user’s choice. OK. Let each calling window handle that detail. Don’t involve your modal window in that. Just let it return whether to save changes or not.

[quote=25347:@John Allen]Thanks for the reply.
Return value from the “save changes” is not the problem. I do check the return from the dialog. My problem is that I need to know in the dialog’s open event who called it.[/quote]

Use a constructor instead of the open event ?