Jump to content

Futurebasic/Language/Reference/window statement

From Wikibooks, open books for an open world

WINDOW

[edit | edit source]

Syntax

[edit | edit source]
WINDOW [#]idExpr[,[title$][,[rect][,[type][,class]]]]

Description

[edit | edit source]

Use this statement to do any of the following:

  • Create a new screen window;
  • 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 255.
  • title$ - 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& Long integer expression or POINTER variable which points to an 8-byte struct such as a RECT type.
  • type - a positive or negative integer which specifies the general appearance of the window, and specifies whether it should be "modal" or not (a modal window is always active while it's open; it inhibits the user from selecting another window or a menubar item until the window is closed).
  • class - an integer in the range 0 through 255.

To Create a New Screen Window

  • Specify an idExpr value such that ABS(idExpr) is different from the ID number of any existing window. A new window is created and is assigned an ID number of ABS(idExpr). You can use the window's ID number later to identify the window in other FB statements and functions. If idExpr is negative, the window is created invisibly; it's sometimes useful to create a window invisibly if it will contain controls, edit fields and graphics that may take a long time to build. You can use the WINDOW statement again to make an invisible window visible (see below). When you create a new window, it becomes the current output window. If you create it visibly (and you don't specify the _keepInBack attribute), it also becomes the current active window.
  • title$ assigns a string to the window's title bar (if the window has a title bar). If you omit this parameter, the window will be created without a title.
  • 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 a "default" size and location is created.
  • type specifies the appearance, modality and special attributes of the window (see more below). If you omit this parameter, a non-modal window of type _doc is created, with no special attributes.
  • class specifies an optional "class number" for the window. If your application creates several windows, it's useful to assign the same class number to each window that performs a given kind of function. Later, you can use the WINDOW function to determine the class number of the currently active window and the current output window; this can help your application determine what the window is used for and how to process it. If you omit this parameter, the new window is assigned a class number of zero. 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 change some of the window's characteristics. The window also becomes the current output window. If the window was invisible, it becomes visible. Note: You can't activate the window if you specified the _keepInBack attribute when the window was created, and there are other visible windows open. 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 (unless its _keepInBack attribute is set), 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 (you can't change the window's type nor class after it's been created). 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 not cause an existing window to be centered on the screen. If you want to change an existing window's rectangle so that it's centered on the screen, use a rect parameter that's calculated as follows: DIM rect.8
    x1 = (SYSTEM(_scrnWidth) - myWindowWidth) / 2
    y1 = (SYSTEM(_scrnHeight) - myWindowHeight) / 2
    x2 = x1 + myWindowWidth
    y2 = y1 + myWindowHeight
    CALL SETRECT(rect, x1, y1, x2, y2)

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 (unless its _keepInBack attribute is set). 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, or you specified the _keepInBack attribute when you created the window. 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 OUPTUT 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 Visible

If idExpr is the (positive) ID of a window that currently exists but is invisible, the WINDOW statement makes the window visible, and also generates a DIALOG event of type _wndRefresh. A _wndRefresh event is also generated when you create a new window visibly. (Note: There are also other kinds of actions which generate _wndRefresh events; see the DIALOG function for more information.)

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.

More about the type Parameter

The typeparameter is a positive or negative integer. The absolute value of type
determines the general appearance of the window and determines some special attributes
of it. The sign of type determines whether the window will be modal or non-modal. If
type is negative, the window will be modal, which means the user won't be able to
switch to a different window until the modal window is closed; if the user clicks in an
inactive window while a modal window is active, a beep is generated, but a _wndClick
event is notgenerated. typecan be expressed as follows:

[-](windowVariant [+attribute [+attribute ...]])

windowVariant can be any of the following:

<image was here

_doc (1)

Document window with room for scrollbars.

<image was here

Framed dialog window.

<image was here

_dialogPlain (3)

_dialogShadow (4)

_docNoGrow (5)

_dialogMovable (6)

_docZoom (9)

Plain dialog window.

Shadowed dialog window.

Document window with no grow box.

Movable dialog window.

Document window with zoom box and room for scrollbars.

<image was here

_docRound (17)

Rounded-corner window. Add 1 through 7 to this variant to increase the roundness of the corners.

<image was here

_WDEFbaseID (129)

Palette window with close box. You can add the constant _WDEFhasZoom (8) to this variant to give the window a zoom
<image was here _WDEFbaseID + _WDEFsideDrag (131) Sideways palette. You can add the constant _WDEFhasZoom (8) to this variant to give the window a zoom box.
176 through 191 These values are mapped to Appearance Manager window types 1984 through 1999.
192 through 255 These values are mapped to Appearance Manager window types 1024 through 1087.

The attribute can be any of the following (you can specify as many of these as apply):

<image was here>

See Also

[edit | edit source]

MINWINDOW; MAXWINDOW; SETZOOM; GET WINDOW; WINDOW CLOSE; WINDOW OUTPUT; WINDOW function; DIALOG function; AUTOCLIP

华夏公益教科书