Hi,
Could someone please tell me how I check to see if a window is open, and if so, close it.
I have tried the following code but it fails
if win_Add.Open = true then
win_Add.Close
end if
Thank you all in advance.
Hi,
Could someone please tell me how I check to see if a window is open, and if so, close it.
I have tried the following code but it fails
if win_Add.Open = true then
win_Add.Close
end if
Thank you all in advance.
Window.Open is an event, not a property.
In any case, in general, Windows should only be closed by a user action.
Wasn’t there a similar discussion in the last days?
The window WILL be closed by a user action.
I have a button which says “Close all Windows”, but my code above is wrong - thats why I was asking for help
Create a method:
WindowClose(Nom as string)
for i as integer = 0 to WindowCount - 1
Dim t as Introspection.TypeInfo = Introspection.GetType(window(i))
if t.Name = Nom then window(i).Close
next i
Then use it as
WindowClose "myWindowName"
No need for Introspection.
for i as integer = 0 to WindowCount - 1
if window(i) isa MyWindowType then
if MyWindowType(window(i)).name = nom then
window(i).close
end
end
next i
what is this MyWindowType??
It’s the name of your window in the project tab / navigator. The window “name” is really an object type / class name.
Sorry, but if I write
for i as integer = 0 to WindowCount - 1
if window(i) isa wEdit then
if wEdit(window(i)).name = nom then
window(i).close
end
end
next i
I get this error:
[quote]This item doesn’t exist
if wEdit(window(i)).name = nom then[/quote]
What am I doing wrong?
Thanks.
Windows don’t have a Name. Bob obviously mixed window code with control code. The extra check for Name isn’t needed with windows, but is appropriate for controls.
for i as integer = 0 to WindowCount - 1
if window(i) isa wEdit then
window(i).close
end
next i
Ok.
Thanks a lot.
Hello,
A more flexible and basic solution.
1/ In a module :
Public Property StatutInterfaceActive as Boolean = False
2/ On The Windows you want to check for :
Sub Open() Handles Open
CheckWindowActive = True
End Sub
3/ The Check Method whereever you want :
If CheckWindowActive then
YouNameWindow.Close
End if
Worked for me to Make Window2 Modal move with my Window1 Main Window