Window closes and disappears but is not Nil?

I’m somewhat puzzled. I have a property

Public Property winPrefs as winPreferences

for my app and the following menu handler:

Function MenuPreferences() As Boolean
  If winPrefs = Nil Then
    winPrefs = New winPreferences  // is invisible
  End If
  Return True
End Function

If I show and close the Preferences window then I can’t get it back - it isn’t Nil but it isn’t showing in the debugger either …

Feeling a bit dumb - can anyone give me a hint?

hide is the opposite of show, close is the opposite of open

you show the window, then close it, can’t be shown again if not open

(guessing here, as I don’t normally close windows unless I’m shutting down, otherwise I just hide)

Once you “close” a window you should drop references to it
So either make WinPrefs a weakRef
Or override winPrefs.CancelClose to just hide the window and return true

Yeah I know not intuitive at all

CancelClose will need to be something like

If appquitting the 
  Return False
End If


Return True
1 Like

Yeah, I came to the same conclusion in the end.

I did remember something like “app quitting” but couldn’t find appQuitting, I had tried app.quitting instead :man_facepalming:

You’d think searching the online help for quit or quitting would bring up appQuitting but no …

Application has AutoQuit but that would still not help because that window isnt closed
Its just not visible