Passing arguments to a Window.ShowModal call

I’m sure this has been discussed ad nauseum but I can’t find it. I’ve tried a number of options and my only success has been creating a global class and the getting the contents of that class when the Window opens. There’s nothing regarding this in the language reference.

Isn’t there a way to pass arguments to a Window’s Open/Show/ShowModal call?

I’ve been putting a Constructor (with my own parameters and logic) on the Window, then calling it like the following:

Var w As Window = New Window2(id) w.Show
Note: Implicit Instance is False.

Is that what you’re looking for?

I implement an Initialise method that gets called between creating the instance and showing the dialog.

[code]Dim theDialogObj As wDialog

theDialogObj = New wDialog
theDialogObj.Initialise(parameters)
theDialogObj.Show[/code]

Thanks Scott and Kevin!

I suspect that my archaic dependence on Implicit window instances is my downfall here. I had added Constructor() methods to this and a couple of other windows, but it never dawned on me that the Constructor() was executed when the implicit instance was created …

Thanks for those pointers. Another crutchthing to consider when refactoring old-world projects.

I overload the showmodal method and as a picture is worth a thousand words you can have a look at this demo project which also shows how to return a value from a modal window.

1 Like

So obvious that I feel a bit embarrassed. The use of overloaded events needs to be a series of Xojo vids. I was so busy working AROUND what I thought was a missing feature, I’ve never once in my 16+ years of using RB/RS/Xojo used the combobox feature when adding a new method to a window …

Hey @Paul Lefebvre - how about a new series on things like this?

Don’t. It took me ages to work this out. Mostly tips from @Norman Palardy here & elsewhere. Thanks for the tip on the combobox - I just typed in the method name - that exposes a lot of options I have yet to discover :slight_smile:

BTW I’ve updated that demo project and added comments along with renaming the controls. The action button on the dialog has comments worth looking at :slight_smile: