Stop Window Auto Showing

  1. 5 weeks ago

    Graham B

    Jan 10 Pre-Release Testers, Xojo Pro The Canada's

    Is there a reason a non implicit instance window auto shows when it goes out of scope?

    Sub Action() Handles Action
      dim w as new window2()
    //fail some validation setting up window - so dont show it
    End Sub

    The window always appears. Surely you have to call show , showmodal , hide etc to show it.

    Is close the only way to ensure it is not shown?

    Xojo 2019r1.1 macOS

  2. Jean-Yves P

    Jan 10 Pre-Release Testers, Xojo Pro Europe (France, Besançon)

    set the window implicit instance property to false and it will not show, you will have to call w.show

  3. Graham B

    Jan 10 Pre-Release Testers, Xojo Pro The Canada's

    it is set to false.

    Is there a reason a non implicit instance window

  4. Julian S

    Jan 10 Pre-Release Testers, Xojo Pro UK

    It doesn't show when it goes out of scope, it shows when it comes into scope on the dim

    Set the window visibility to false in the inspector if you don't want it to show then set visible to true in code when you want to show it.

  5. Paul M

    Jan 10 Pre-Release Testers, Xojo Pro Eastern Massachusetts, USA

    You will also want to set Visible to false.

  6. Paul M

    Jan 10 Pre-Release Testers, Xojo Pro Eastern Massachusetts, USA

    (Julian beat me to it)

  7. Derk J

    Jan 10 Pre-Release Testers, Xojo Pro

    What's the fame type set to?
    It should NOT show by just creating a new instance as far as my knowledge

  8. Graham B

    Jan 10 Pre-Release Testers, Xojo Pro The Canada's

    Window frame is a document, setting to other types does nothing.

    Seems like a bug to me.

    dim w as new window2()
    
    MsgBox "here"
    

    The window shows on MsgBox "here"

    What if i want to show it within a certain window etc. I could not get to that code.

    Also even if i never call show, with visible set to false it is still registered as an open Window in WindowCount.
    I have to call close on the window to remove it.

  9. Graham B

    Jan 10 Pre-Release Testers, Xojo Pro The Canada's
    dim w as new window2()
    w.Visible = false
    
    if not w.Action_Init() then
      w.close()
      return
    end if
    
    w.ShowModalWithin(myParentWindow)

    This appears to be the logic i have to implement to get it to work as I expected.

  10. Derk J

    Jan 10 Pre-Release Testers, Xojo Pro
    Edited 5 weeks ago

    @Graham B Window frame is a document, setting to other types does nothing.

    Seems like a bug to me.

    dim w as new window2()
    
    MsgBox "here"
    

    The window shows on MsgBox "here"

    What if i want to show it within a certain window etc. I could not get to that code.

    Also even if i never call show, with visible set to false it is still registered as an open Window in WindowCount.
    I have to call close on the window to remove it.

    The window should NOT be shown* but the Open Event should fire as that has to do with constructing the window. E.g. set the properties in the open event. If the default IDE setting is visible or the Open even has Self.Visible = True then it could possibly show.

    * unless you specify to do so in the Window.Open event

    Sounds like a bug, i think you should make sure the Open event doesn't have visibility code in it.

  11. Graham B

    Jan 10 Pre-Release Testers, Xojo Pro The Canada's

    There is nothing in the window2 class, it's from a simple test app. Only change made is turning off implicit instance.

  12. Dave S

    Jan 10 San Diego, California USA

    Ah..... IMPLICIT INSTANCE means that it is implied that a "NEW WINDOW" command is automatically executed, this normally causes the window in question to appear.

    You did NOT have Implicit Instance, However, you did say "NEW WINDOW2".... which is an EXPLICIT INSTANCE, and therefore causes the window to appear

  13. Norman P

    Jan 10 Pre-Release Testers, Xojo Pro outside listening to the silen...

    @Dave S Ah..... IMPLICIT INSTANCE means that it is implied that a "NEW WINDOW" command is automatically executed, this normally causes the window in question to appear.

    You did NOT have Implicit Instance, However, you did say "NEW WINDOW2".... which is an EXPLICIT INSTANCE, and therefore causes the window to appear

    It should not not if the Visible property in the IDE is set to false
    basically that lets you create an instance, manipulate it without showing it

  14. Julian S

    Jan 10 Pre-Release Testers, Xojo Pro UK

    Graham, can you post up a small demo project where this is happening?

  15. Graham B

    Jan 10 Pre-Release Testers, Xojo Pro The Canada's

    Create a new project
    Add a new window (called window2)
    Turn off implicit instance for window2
    Add a button on window1 and add action event handler and add this code

    dim w as new window2()
    
    MsgBox "here"
    
    w.Show()

    run it and notice window2 appears when msg box appears

    Or only call dim w as new window2() in the action event.

  16. Graham B

    Jan 10 Pre-Release Testers, Xojo Pro The Canada's

    So for all non implicit windows i need to turn off visible in the IDE and also ensure i close it if i return before showing it? (otherwise window stays in memory and is listed in WindowCount)

  17. Julian S

    Jan 10 Pre-Release Testers, Xojo Pro UK
    Edited 5 weeks ago

    You need to go into the inspector for windows2 and unckeck Visible

    -image-

  18. Graham B

    Jan 10 Pre-Release Testers, Xojo Pro The Canada's

    And if you dont show it, it will stay around in memory, unless you close it, even though you never showed.

    Windows are strange.

  19. Tim H

    Jan 10 Pre-Release Testers Portland, OR USA

    Windows don't go "out of scope" because the framework holds a reference to them, so the reference count never goes to zero. They are different than "normal" objects in that you're not the only one who cares about them.

or Sign Up to reply!