Invisible window re-appears

  1. 10 months ago

    Dick B

    1 Feb 2017 Pre-Release Testers, Xojo Pro Amsterdam

    I have several windows say W1, W2 etc. Initially my W1 is set visible. Then upon a button-click I issue W1.visible = false and W2.visible = true and this process is repeated for subsequent windows.
    However W1 might be re-appearing when I switch from W2 to W3. As front window so even hiding W3. This behavior is different in OSX and Windows but the problem occurs for both platforms. I have tried to get rid of W1 by W1.close and to force other windows to be in front by Wi.show. That is not helping. I am afraid I have a deep misunderstanding somewhere. Please help.

    @!@#$% B However W1 might be re-appearing when I switch from W2 to W3. As front window so even hiding W3. This behavior is different in OSX and Windows but the problem occurs for both platforms. I have tried to get rid of W1 by W1.close and to force other windows to be in front by Wi.show. That is not helping. I am afraid I have a deep misunderstanding somewhere. Please help.

    @!@#$% B I do turn instance off, many references if not all references to the W1 give an error message telling me that the W1 doesn't exist and errors like 'static reference to instance method:.....'

    Admitting Implicit instance is off and visible false, the reason why a window reappears could be the show command.

    Go through your code and check that W1.Show has not slipped through.

  2. turn implicit instance off on W1

  3. Dick B

    1 Feb 2017 Pre-Release Testers, Xojo Pro Amsterdam

    Hi Norman, thanks but if I do turn instance off, many references if not all references to the W1 give an error message telling me that the W1 doesn't exist and errors like 'static reference to instance method:.....'

  4. Edited 10 months ago

    Right
    I expect those are whats causing your window to reappear when you dont want it to
    IF its been closed then a use like

       W1.<some property name> = <value>

    or

       <some variable> = W1.<some property name>

    causes an instance to be created and this may make it show up

    see http://developer.xojo.com/userguide/desktop-windows (implicit instances)

  5. Bob K

    1 Feb 2017 Pre-Release Testers, Xojo Pro Kansas City

    Implicit Instance is Evil: http://www.bkeeneybriefs.com/2016/01/implicitinstance-is-evil/

  6. Michel B

    1 Feb 2017 Pre-Release Testers, Xojo Pro Answer

    @!@#$% B However W1 might be re-appearing when I switch from W2 to W3. As front window so even hiding W3. This behavior is different in OSX and Windows but the problem occurs for both platforms. I have tried to get rid of W1 by W1.close and to force other windows to be in front by Wi.show. That is not helping. I am afraid I have a deep misunderstanding somewhere. Please help.

    @!@#$% B I do turn instance off, many references if not all references to the W1 give an error message telling me that the W1 doesn't exist and errors like 'static reference to instance method:.....'

    Admitting Implicit instance is off and visible false, the reason why a window reappears could be the show command.

    Go through your code and check that W1.Show has not slipped through.

  7. Jeff T

    1 Feb 2017 Midlands of England, Europe

    many references if not all references to the W1 give an error message telling me that the W1 ...

    If W1 is the NAME of the window, referring to it with implicit instance turned on will show one copy of the window
    If implicit instantiation is off, you will get an error.

    Create an app level or global variable called instanceOfW1
    Set that to be = new W1
    Set instanceOfW1.visible = false if you like

    After that, talk to instanceOfW1 , not W1

  8. Dick B

    21 Feb 2017 Pre-Release Testers, Xojo Pro Amsterdam

    Sorry about the delay in re-rising this issue. I have now a window created with 'instance off'. Call it W1. It's visibility property = false.
    That W1 has some code say 'checkRNG' in the open event.

    I have the following global property Instance_of_W1 as Window
    and in App.open I have the code:
    instanceofW1 = New W1

    This apparently works because the instanceofW opens but ......
    a) it is visible without telling instanceofW1.visible = true
    b) it opens twice! The code in the open event 'checkRNG' is executed twice

    I suspect that for some reason two instances have been created. Maybe it's because this un-instantiated W1 was the first window but moving it later in the project makes no difference. What is going on here?

  9. Dick B

    21 Feb 2017 Pre-Release Testers, Xojo Pro Amsterdam

    I have now a minimal program. Just one window W1 not instantiated. The W1.open method has a msg box("test") in it. In the App.open I make a new instance of the window instanceofW1 = New W1 and this results in two windows each doing the msgbox. When I make the W1 invisible then I see the msg box still twice but only one window appears after both msg boxes have been OK'ed. The is either radically wrong or I am radically not understanding what is going on. !@#$%

  10. Dick B

    21 Feb 2017 Pre-Release Testers, Xojo Pro Amsterdam

    I looks like the the automatically available first window in a new project gets a special status and will always be opened (even if you set it uninstantiated). I create a project with a second windows W2 and tried to instantiate instance_of_W2 and then is only one open event triggered for instance_of_W2.
    Can I set something i app.open to avoid automatic opening of the first window that was created with the project creation?

  11. Michel B

    21 Feb 2017 Pre-Release Testers, Xojo Pro
    Edited 10 months ago

    Don't use MsgBox for debug purposes. It modifies the order of windows and of events.

    Instead, use System.Debuglog , as advised in the LR.

    • Instead of playing with instances of W1, create a W2 window, invisible, implicit instance off. Change it's title to W2
    • Add InstanceOfW2 as W2 to W1.
    • On W2, drag two buttons
    • Call one PbInstance, with inside Action:
    InstanceOfW2 = new W2
    System.Debuglog InstanceOfW2.Title

    - In the second button called PbShow Action, put :

    InstanceOfW2.show

    When you click PbInstance, the window is created, but it remains invisible. The title will be shown in the Messages pane of the IDE (third icon in the bottom middle of the IDE), showing the window actually exists, but it is invisible.

    When you click PbShow, the window appears.

    You could have a third PbHide button, with inside :

    InstanceOfW2.hide

    If you need to call W2 from anywhere in the program, drag a module into the project, attach InstanceOfW2 to it, and make it global.

  12. Dick B

    21 Feb 2017 Pre-Release Testers, Xojo Pro Amsterdam

    Hi Michel, I did put msg box in the open method to see if that method was called twice while I only want a single window to open.
    I realize msgbox might mix up orders but it should not repeat itself ;-).
    I have now added a window and copied all stuff from the original W1 to this one. Set it uninstantiated and create an instance in app.open and everything is fine now. My suspicion is that app always will try to open the window that was created automatically when one starts a new project even if that window is uninstantiated. It forces an instance. Calling a new instance then creates the second instance. Thanks for all help.

  13. Bob K

    21 Feb 2017 Pre-Release Testers, Xojo Pro Kansas City

    Do you have the DefaultWindow property set in app object? That would explain why it's always opening that window regardless if you've called it or not. Many people forget about this property.

or Sign Up to reply!