I know I am doing something slightly wrong here. I am testing for an Open Window STATICALLY via the following Function (which works fine) however it is not dynamic.
Function fOpenPrefWinCheck() As Boolean
Dim n as Integer = WindowCount
for i as integer = 0 to n-1
if Window(i) isa Preferences_Window then
Return True
Exit
Else
end if
next
End Function
I have been trying to replace the ISA Preferences_Window with ISA InWindow (which InWindow is a variable passed into the function as a WINDOW).
This isn’t working for me as the compiler says “There is no class with this name if Window(i) Isa InWindow then”
Am I limited to having to have a specific function like this per window?
Without testing, I think you’re running into the trickery that Xojo pulls where windows are concerned, i.e., a window can be both a subclass of Window and and instance of that window. When you pass it in a parameter, you are passing the instance, not the class, so you cannot use IsA.
Again without testing, Introspection might help here.
Something like this seems to work (warning, it’s only been tested for a simple scenario):
Dim inputWin as Introspection.TypeInfo
inputWin=Introspection.GetType(InWindow) //Pass in InWindow as Window
Dim n as Integer = WindowCount
dim thisWin as Introspection.TypeInfo
for i as integer = 0 to n-1
thisWin = Introspection.GetType(window(i))
if thisWin.Name = inputWin.Name then
Return True
Exit
Else
end if
next
Bill every time i iterate through this function it always returns true even when the window is hiding or not open. How did you test that on your side? Thanks again!!
I’m a little confused. In order to pass a window to the function, it has to already exist, which means it will always be open and in the list of windows. There is no way to pass the class name to a function, you have to pass an instance. Which means you have to have an open window to pass.