How to refresh opened window?

  1. 5 months ago

    Aditya N

    Jun 29 Pre-Release Testers, Xojo Pro

    I have a non main-window opened, when calling a function inside the window, it opened a new instance of the non-main window instead of refreshing or updating the current opened one.

    I have tried to put Me.Invalidate in the last line of the code in the aforementioned 're-opened' window part.

    Also have tried to call WindowName.Invalidate from other Window that is wanted to refresh that opened window. But it's still opening new instance of the window!

    How to properly called a function in the already opened non-main window ?

    If the window’s ImpliciteInstance property is False or you have created it using new and you are not keeping a reference to it somewhere, you have to search the available windows and address the right one, like:

    For q as Integer = windowcount-1 downto 0
       Dim w as window = window(q)
       if w isA YourWindowName Then
         YourWindowName(w).YourMethod
         Exit For
      End If
    Next

    EDIT: You have to replace YourWindowName with the name of your window subclass, of course.

  2. Ulrich B

    Jun 29 Pre-Release Testers, Xojo Pro Answer Europe (Germany, Berlin) · xo...
    Edited 5 months ago

    If the window’s ImpliciteInstance property is False or you have created it using new and you are not keeping a reference to it somewhere, you have to search the available windows and address the right one, like:

    For q as Integer = windowcount-1 downto 0
       Dim w as window = window(q)
       if w isA YourWindowName Then
         YourWindowName(w).YourMethod
         Exit For
      End If
    Next

    EDIT: You have to replace YourWindowName with the name of your window subclass, of course.

  3. Aditya N

    Jun 29 Pre-Release Testers, Xojo Pro

    Neat, thanks, is there any doc or snippets on how to keep reference with the window?. Why does it was happened even my ImpliciteInstance is set to true?

  4. Ulrich B

    Jun 29 Pre-Release Testers, Xojo Pro Europe (Germany, Berlin) · xo...
    Edited 5 months ago

    A window is a(n instance of a) class, so keeping a reference would be like with every class:
    You create a property of that kind, or a dictionary or array, which you assign or append this window instance to.

    Windows in Xojo are a special kind of beast: You can consider every window you create in the IDE being a custom subclass of the window class. You should only set ImplicitInstance to True if this window will be a one-shot kind, like (often) a mainwindow or something that will appear only once in your app.
    In this cases, you should not create a new instance of this window subclass (Dim w as New MyWindow), but use the Window name as property throughout your app.

    In the other cases, either keep a reference to the window like mentioned above or search its instance(s).

    EDIT: The main difference to most other classes is that a window is self-referencing, so while it has not been closed, it will stay alive even if it has not been assigned to a property of a longer-living instance.

or Sign Up to reply!