Passing arguments to a Window.ShowModal call

  1. 7 weeks ago

    Tim J

    Feb 17 Pre-Release Testers, Xojo Pro N. Phoenix, AZ

    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?

    @Tim J 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?

  2. Scott C

    Feb 17 Pre-Release Testers, Xojo Pro Answer twitter.com/ScottCadillac

    @Tim J 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?

  3. Kevin G

    Feb 17 Pre-Release Testers, Xojo Pro Gatesheed, England

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

    Dim theDialogObj As wDialog
    
    theDialogObj = New wDialog
    theDialogObj.Initialise(parameters)
    theDialogObj.Show
  4. Tim J

    Feb 17 Pre-Release Testers, Xojo Pro N. Phoenix, AZ

    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.

  5. Wayne G

    Feb 17 Pre-Release Testers, Xojo Pro, MVP Auckland, New Zealand

    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.

  6. Tim J

    Feb 17 Pre-Release Testers, Xojo Pro N. Phoenix, AZ
    Edited 7 weeks ago

    @Wayne G 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.

    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 L - how about a new series on things like this?

  7. Wayne G

    Feb 17 Pre-Release Testers, Xojo Pro, MVP Auckland, New Zealand

    @Tim J I feel a bit embarrassed.

    Don't. It took me ages to work this out. Mostly tips from @Norman P 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 :)

    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 :)

or Sign Up to reply!