Syntax:
window idExpr[, [titleString][, rect]]]
Description:
A simplified form of the appearance window statement. Use the window
statement to do any of the following:
- Create a new screen window, with a limited range of options;
- Activate (highlight and bring to the front) an existing window;
- Make an existing window visible or invisible;
- Alter the title or rectangle of an existing window.
The parameters should be specified as follows. They are interpreted
slightly differently depending on whether you are creating a new window
or altering an existing one.
idExpr
- a positive or negative integer whose absolute value is in the range 1 through 2147483647 (_maxLong).
titleString
- a string expression.
rect
- a rectangle in global screen coordinates. You can express it in either of two forms:
(x1,y1)-(x2,y2)
Two diagonally opposite corner points.
rectAddr
Pointer expression or variable that points to a Rect
record.
To Create a New Screen Window
- A new document window is created if
abs( idExpr )
differs from the ID number of any existing window. The new window is assigned an ID number of abs(idExpr)
. You can use the window's ID number later to identify the window in other FutureBasic statements and functions. If idExpr
is negative, the window is created invisibly. When you create a new
window, it becomes the current output window. If you create it visibly
it also becomes the current active window.
title$
assigns a string to the window's title. If you omit this parameter, the window will be created "untitled".
rect
specifies the initial
size and location of the window's content rectangle. Note that rect
does not include the window's frame. This parameter is interpreted in a
special way if you specify an upper-left coordinate of (0,0) in rect
;
in this case, the window is centered in the screen, and its width and
height are determined by the right and bottom coordinates of rect
.
Note that this special interpretation applies only when you're creating
a new window. If you omit this parameter, a window of default size and
location is created.
To Activate an Existing Window
- Specify the (positive) ID number of an existing window in
idExpr
.
You do not need to specify any of the other parameters, unless you also
wish to to change some of the window's characteristics. The window also
becomes the current output window. If the window was invisible, it
becomes visible.
To Make an Existing Window Visible or Invisible
- To make a window visible, specify the (positive) ID number of an existing window in
idExpr
. The window also becomes the current active window, and it becomes the current output window.
- To make a window invisible, specify the negative of an existing window's ID number in
idExpr
.
The window becomes the current output window. If it was the active
window, it becomes inactive (possibly forcing another window to become
active).
You do not need to specify any of the other parameters, unless you also
want to change some of the window's characteristics.
To Alter the Characteristics of an Existing Window
- Specify the ID number of an existing window (or its negative) in
idExpr
, and specify a new title$
and/or rect
parameter. If you omit any parameter, the corresponding characteristic won't change. Note that the rect
parameter
is interpreted slightly differently when you're altering an existing
window, as opposed to creating a new window; in particular, specifying
an upper-left coordinate of (0,0) will move an existing window so that
it is partly under the menu bar. If you want to change an existing
window's rectangle so that it's centered on the screen, use a rect
parameter calculated as follows:
dim as Rect myRect
x = (system(_scrnWidth) - myWindowWidth) / 2
y = (system(_scrnHeight) - myWindowHeight) / 2
SetRect( myRect, x, y, x + myWindowWidth, y + myWindowHeight )
Note: If you specify the window's (positive) ID number when you
alter a window's characteristics, the window also becomes the current
active window
. If you specify the negative of the window's ID number, the window becomes invisible.
Side Effects of Activating the Window
The window
statement always makes the window active, unless you specify a negative idExpr
. When you activate a window using the window
statement, the following things also happen:
- The window also becomes the current output window. (See the
window output
statement to learn how to specify an output window that's different from the active window.)
- A dialog event of type
_wndActivate
is generated. (There are also other kinds of actions which generate _wndActivate
events; see the dialog
function for more information.)
- Any previously-active window becomes inactive (this also generates a separate
_wndActivate
dialog event).
Side Effects of Making a Window Invisible
If idExpr
is negative, the window becomes invisible, and it becomes the current
output window. If the window was previously active, it becomes
inactive; if your program has other visible windows, one of them
becomes the active window.
Customising the Console window
The automatically created default Console window can be customised using an idExpr of _FBConsoleWndNum. For example, to maximise the height, use:
include "ConsoleWindow"
window _FBConsoleWndNum, "My Console Window", (5,50)-(500, system( _scrnHeight ) - 5 )
See Also:
appearance window; window close; window output; window function; dialog function