DEFINE WINDOW Command
Creates a window and specifies its attributes.
DEFINE WINDOW WindowName1 FROM nRow1, nColumn1 TO nRow2, nColumn2 | AT nRow3, nColumn3 SIZE nRow4, nColumn4 [IN [WINDOW] WindowName2 | IN SCREEN | IN DESKTOP [NAME ObjectName] [FONT cFontName [, nFontSize [, nFontCharSet]]] [STYLE cFontStyle] [FOOTER cFooterText] [TITLE cTitleText] [HALFHEIGHT] [DOUBLE | PANEL | NONE | SYSTEM | cBorderString] [CLOSE | NOCLOSE] [FLOAT | NOFLOAT] [GROW | NOGROW] [MDI | NOMDI] [MINIMIZE | NOMINIMIZE] [ZOOM | NOZOOM] [ICON FILE FileName1] [FILL cFillCharacter | FILL FILE FileName2] [COLOR SCHEME nSchemeNumber | COLOR ColorPairList]]
Specifies the name of the window to create. Window names can be up to 254 characters long in Visual FoxPro. They must begin with a letter or underscore, and cannot begin with a number. They can contain any combination of letters, numbers and underscores.
- FROM nRow1, nColumn1TO nRow2, nColumn2
Specifies the position and size of the user-defined window on the main Visual FoxPro window. FROM nRow1, nColumn1 specifies the position of the upper-left corner of the user-defined window on the main Visual FoxPro window. TO nRow2, nColumn2 specifies the position of the lower-right corner of the user-defined window on the main Visual FoxPro window.
A window can be defined with coordinates that lie outside the Visual FoxPro window border and can be larger than the main Visual FoxPro window.
The window's location and size are determined by the font of the window's parent. The window's parent can be another user-defined window or the main Visual FoxPro window.
- AT nRow3, nColumn3SIZE nRow4, nColumn4
Specifies the position and size of a user-defined window.
AT nRow3, nColumn3 specifies the position of the upper-left corner of the user defined window on the main Visual FoxPro window. This position is determined by the current font of the window's parent. Because the AT clause is identical to the FROM clause in all respects, the two clauses can be used interchangeably.
SIZE nRow4, nColumn4 specifies in rows and columns the size of the user-defined window and ensures that text displayed in a specific font will fit in the window you create.
You can specify a font and font style for a user-defined window by including the FONT and STYLE clauses. If you specify a font for the window and include the SIZE clause, its size is determined by the window's font height and width. If you don't specify a font for a window, the window's font is the default system font, 10-point FoxFont.
- IN [WINDOW] WindowName2
Places a user-defined window in a parent window. The user-defined window becomes a child window and cannot be moved outside the parent window. If the parent window is moved, the child window moves with it.
When a child window is placed in a parent window, the child window coordinates specified with the FROM and TO clauses or the AT and SIZE clauses are relative to the parent window, not the main Visual FoxPro window.
In the following example, a parent window, wParent, is created. A child window, wChild, is placed in the parent window.
CLEAR DEFINE WINDOW wParent ; FROM 1, 1 TO 20, 30 ; TITLE "Parent" && Parent window. ACTIVATE WINDOW wParent DEFINE WINDOW wChild ; FROM 1, 1 TO 20, 20 ; TITLE "Child" ; IN WINDOW wParent && Child window. ACTIVATE WINDOW wChild ACTIVATE SCREEN WAIT WINDOW 'Press a key to clear the windows' RELEASE WINDOW wParent, wChild CLEAR
- IN SCREEN
Explicitly places a user-defined window on the main Visual FoxPro window. If you omit IN SCREEN, the user-defined window is placed on the main Visual FoxPro window by default.
You can include the IN WINDOW clause in ACTIVATE WINDOW to place the window in another user-defined window and override this IN SCREEN clause.
- IN DESKTOP
Places a user-defined window on the Microsoft Windows desktop, outside the main Visual FoxPro window. The position of the window is relative to the Windows desktop, and the current font of the main Visual FoxPro window.
- NAME ObjectName
Creates an object reference for the window, allowing you to manipulate the window with object-oriented properties available for the form object.
For additional information about object-oriented programming in Visual FoxPro, see. For additional information about the form object properties you can specify for a window created with the NAME clause, see the topic.
- FONT cFontName[, nFontSize [, nFontCharSet]]
Specifies a font for text placed in the window. cFontName specifies the name of the font and nFontSize specifies the point size. If you omit nFontSize, a 9-point font is used. You can specify a language script with nFontCharSet. See the for a list of available language script values.
For example, this command creates a window that displays output directed to the window in a 16-point Courier font:
DEFINE WINDOW wDisplayFont FROM 2,2 TO 12,22 FONT 'Courier', 16
If you omit the FONT clause, a 10-point FoxFont is used. If the font you specify is not available, a font with similar font characteristics is substituted.
- STYLE cFontStyle
Specifies a font style for text placed in the window. cFontStyle specifies the font. If you omit the STYLE clause, or if the font style you specify is not available, the Normal font style is used.
The following table lists font styles and their corresponding characters.
Character Font style
You can include more than one character to specify a combination of font styles. In Visual FoxPro, the following commands specify the style Bold Italic:
DEFINE WINDOW wDisplayStyle FROM 2, 2 TO 12, 22 STYLE 'BI'
- FOOTER cFooterText
Included for backwards compatibility. Ignored in Visual FoxPro Windows versions.
- TITLE cTitleText
Assigns a title with the TITLE clause. cTitleText specifies the title's text and is centered in the top border of the window. If the title is wider than the window, the title is truncated.
Creates a window with a half-height title bar. This provides compatibility for windows created in previous versions of FoxPro that are imported into Visual FoxPro.
When you use DEFINE WINDOW to create a window, a half-height title bar is used, unless you include the SYSTEM keyword or you include a FONT clause.
If you include the HALFHEIGHT keyword, a half-height title bar is used regardless of whether the SYSTEM or FONT clause is included.
- DOUBLE | PANEL | NONE | SYSTEM | cBorderString
Specifies a border style for a user-defined window. The default border is a single line.
Specifies a double-line border around the window.
Specifies a wide border around the window.
Suppresses the border entirely.
Specifies the user-defined window to look like a system window. When you include certain other clauses (GROW, ZOOM, and so on), the appropriate window controls are placed in the window's border.
Specifies a custom border. For more information on defining a custom border, see.
Including DOUBLE or a custom border string creates a window with the PANEL border. Including the CLOSE, FLOAT, GROW, ZOOM, or MINIMIZE clauses places the appropriate controls on the window even if the SYSTEM window definition clause is not included.
Allows the user to close a user-defined window using the keyboard or mouse. Closing a window removes it from the main Visual FoxPro window or a parent user-defined window and removes its definition from memory. If you omit CLOSE, you cannot close the window using the interface; the window must be closed using a command in a program or in the Command window.
Prevents the window from being closed except by a command in a program or in the Command window.
Allows the window to be moved using the keyboard or mouse. If you omit FLOAT, you cannot move the window except using the MOVE WINDOW command in a program or in the Command window.
Prevents the window from being moved except by using the MOVE WINDOW command in a program or in the Command window.
Allows you to resize a user-defined window using the keyboard or mouse. If you omit GROW, you cannot size the window except using the SIZE WINDOW command in a program or in the Command window.
Prevents the window from being resized except by the SIZE WINDOW command in a program or in the Command window.
Creates a user-defined window that is MDI-compliant. MDI (multiple document interface) is a specification that allows multiple document windows and determines their structure and behavior. If you omit MDI, the window you create isn't MDI-compliant.
When an MDI-compliant window is maximized:
The window assumes the size of the main Visual FoxPro window. The window's controls disappear and its pop-up menu icon appears in the Visual FoxPro system menu bar. The window's Restore button is also placed in the Visual FoxPro system menu bar.
The window title is placed in the Visual FoxPro title bar and is separated from the Visual FoxPro title by a hyphen.
If you activate another MDI-compliant window, it is automatically maximized.
Creates a window that isn't MDI-compliant.
Allows you to minimize a user-defined window using the keyboard or mouse.
Prevents the window from being minimized.
Allows the window to be maximized using the keyboard or mouse. You can also restore the window to its original size.
Prevents the window from being maximized.
- ICON FILE FileName
Specifies the icon that displays when the window is minimized. You must include the MINIMIZE keyword in DEFINE WINDOW. You can specify only an icon (.ico) file; you cannot specify a bitmap (.bmp) file.
- FILL FILE FileName2
Specifies wallpaper (the background) for the window. The window is tiled with the specified FileName2. You specify a .bmp bitmap file.
- COLOR SCHEME nSchemeNumber
Specifies the colors for the user-defined window. By default, the colors of windows created with DEFINE WINDOW are controlled by color scheme 1.
- COLOR ColorPairList
Specifies the colors for the user-defined window.
After user-defined windows are created with DEFINE WINDOW, they can be displayed in the main Visual FoxPro window with ACTIVATE WINDOW or SHOW WINDOW. The number of user-defined windows you can create is limited only by the amount of available memory and system resources.
Activated windows remain in the main Visual FoxPro window until DEACTIVATE WINDOW or HIDE WINDOW is issued. DEACTIVATE WINDOW and HIDE WINDOW remove windows from the main Visual FoxPro window but don't remove the window definitions from memory. Windows can be placed back in the main Visual FoxPro window with ACTIVATE WINDOW or SHOW WINDOW.
Use CLEAR WINDOWS or RELEASE WINDOWS to remove windows from the main Visual FoxPro window and window definitions from memory. Windows whose definitions have been removed from memory must be recreated with DEFINE WINDOW in order to be redisplayed.
In the following example, a window named output is created and activated. The program waits for you to press a key and then hides the window. The program waits for you to press a key again and then redisplays the window.
CLEAR DEFINE WINDOW output FROM 2,1 TO 13,75 TITLE 'Output' ; CLOSE FLOAT GROW ZOOM ACTIVATE WINDOW output WAIT WINDOW 'press any key to hide window output' HIDE WINDOW output WAIT WINDOW 'press any key to show window output' SHOW WINDOW output WAIT WINDOW 'press any key to release window output' RELEASE WINDOW output