Window Function

Returns a reference to an open window.

Syntax
result = Window( WindowNumber )

Parameters
WindowNumber | Integer | The number of the window you want a reference to.

Return Value
Result | Window | A reference to the window whose number was passed.

# Notes

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.

# Example

This example places the titles of all open windows into a ListBox:

Dim i as Integer
Dim WindowTitle as String
If WindowCount > 1 then
For i=0 to WindowCount-1
WindowTitle=Window(i).Title
ListBox1.AddRow windowTitle
Next
Return Nil
End If

This example gets the frontmost Document window. It considers only Document windows (Frame=0) takes into account the possibility that a window might not be visible:

Dim i,wc as Integer
' Compute the total number of windows for iteration.
wc = WindowCount - 1
' Go through the window list.
For i = 0 to wc
' Is this a visible document window?
If (Window(i).Frame = 0) and Window(i).visible then
' This is the fist visible document window.
Return Window(i)
end if
Next

# See Also

WindowCount function; Window class.