[SOLVED] how to close a non modal window

Post your Gambas programming questions here.
Post Reply
User avatar
sadams54
Posts: 143
Joined: Monday 9th July 2018 3:43am
Contact:

[SOLVED] how to close a non modal window

Post by sadams54 »

I am bringing up a non modal window from code. Sometime later I need to close the non modal window from different code. I just can't figure out how to do this. I tried fWindow.close and no go.
Last edited by sadams54 on Tuesday 21st November 2023 1:21am, edited 1 time in total.
User avatar
sadams54
Posts: 143
Joined: Monday 9th July 2018 3:43am
Contact:

Re: how to close a non modal window

Post by sadams54 »

sorry, I solved it myself but here is the answer....
I created a sub to find the window and close it

Code: Select all

Sub KillLCarsVisual()
  Dim D As Window

  For Each D In Windows
    If d.Name = "FLCARSVisual" Then 
      d.Close
    Endif
  Next
  
End
User avatar
BruceSteers
Posts: 1578
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: [SOLVED] how to close a non modal window

Post by BruceSteers »

It''l depend on the window creation method to use Close() on the object.

for example

Using
fWindow.Show()
statically to open it should then let you use
fWindow.Close()


But this method for example...
Public Sub MakeWin()

  Dim hWin As fWindow = New fWindow
  hWin.Show()

End

With the above method you will have to use hWin.Close not fWindow.Close but hWin is local to the MakeWin() Function so you would have to use the method you have already come up with.

'

But Then this method should work...
Private hWin As fWindow

Public Sub MakeWin()

  hWin = New fWindow
  hWin.Show()

End



With the above method hWin.Close should work as hWin is a global variable of the open window
If at first you don't succeed , try doing something differently.
BruceS
Post Reply