for i As Integer = WindowCount - 1 DownTo 0
if Window(i) isa WndContacts then Window(i).Close
next
Now i want to use this in a method so i don’t have to write it several times in my code. I want to use the WindowName as a Parameter for this method. In my for-next loop, WndContacts is the name of a window. When i just give a string to the parameter (“WndContacts”) i get an error, because the method need a Classname (WndContacts) not a string.
How can i give the Classname as a parameter to the method?
Sub CloseAll (windowInfo As Introspection.TypeInfo)
for i as integer = WindowCount - 1 downto 0
dim ti as Introspection.TypeInfo = Introspection.GetType( Window( i ) )
if ti.FullName = windowInfo.FullName then
Window( i ).Close
end if
next
End Sub
I’m now sitting on a problem where i try to store the position of the window before i close it so i can open it later on the same position. Let me try some things, and maybe i’ll be back later with my question on how to store the window-position.
Create a preferences class or module that includes methods that take a window as a parameter, Store and Restore. In the Window.Close event, call pref.Store( self ) and in Open call pref.Restore( self ). Those methods will know how to save and restore the settings for the window.
Just avoid some “gotchas”. Do not restore a window to a position that would make it invisible to the user, for example, placing it on a second screen that no longer exists. Do not restore Height and Width if they would take those values out of the Min and Max bounds.