From Xojo Documentation
|You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!|
Returns a reference to an open window.
result = Window(WindowNumber)
|result||DesktopWindow||A reference to the window whose number was passed.|
|WindowNumber||Integer||The number of the window you want a reference to. Window 0 is the frontmost window.|
The Window function returns a reference to the window number passed. The window list contains all the windows that have been created. Window zero is the frontmost window. Floating windows are always in front of document windows. For example, to get the frontmost document window when you also have Floating windows, you must also check each window's Frame property. In evaluating the order of windows in the list from front to back, keep in mind that a window may not have its Visible property set to True. If this may be the case, check the Visible property of a window while identifying the frontmost visible window. If you don't, the code may identify the frontmost window as a window that is not Visible.
This function can be used in conjunction with the WindowCount function to loop through the open windows. Note that during a window's Opening event, the window list includes that window, but during a window's Closing event, the window list does not include that window.
If you pass in a window number that does not exist ( a value < 0 or >= WindowCount) then this function returns Nil.
|This function returns only DesktopWindows. Windows of the original Window class will not be returned.|
This code places the titles of all open windows into a DesktopListBox:
Var w As Window = App.Window(i)
If w <> Nil Then
This code gets the frontmost Document window. It considers only Document windows (DesktopWindow.Type=DesktopWindow.Types.Document) and takes into account the possibility that a window might not be visible:
Var lastOffset As Integer = App.WindowCount - 1
For i As Integer = 0 To lastOffset
Var w As Window = System.Window(i)
If (w <> Nil) And (w.Type = Window.Types.Document) And w.Visible Then
frontmostDocumentWindow = w