Using Intel® Visual Fortran to Create and Build Windows*-Based Applications

ID 757211
Date 7/23/2021
Document Table of Contents

Accessing Window Properties

SETWINDOWCONFIG and GETWINDOWCONFIG set and get the current virtual window properties. Virtual window properties set by SETWINDOWCONFIG contain the maximum amount of text and graphics for that unit. The SETWSIZEQQ routine sets the properties of the visible window, which is generally smaller than a virtual window.

If the size of the virtual window (SETWINDOWCONFIG) is larger than the size of the visible window (SETWSIZEQQ), scroll bars are automatically provided to allow all the text and graphics in a virtual window to be displayed.

These virtual window properties are stored in the windowconfig derived type, which contains the following parameters:

TYPE windowconfig
    INTEGER(2) numxpixels            ! Number of pixels on x-axis.
    INTEGER(2) numypixels            ! Number of pixels on y-axis.
    INTEGER(2) numtextcols           ! Number of text columns available.
    INTEGER(2) numtextrows           ! Number of scrollable text lines available.
    INTEGER(2) numcolors             ! Number of color indexes.
    INTEGER(4) fontsize              ! Size of default font. Set to
                                     ! QWIN$EXTENDFONT when using multibyte
                                     ! characters, in which case
                                     ! extendfontsize sets the font size.
    CHARACTER(80) title              ! Window title, where title is a C string.
    INTEGER(2) bitsperpixel          ! Number of bits per pixel. This value
                                     ! is calculated by the system and is an
                                     ! output-only parameter.
                                     ! The next three parameters support multibyte
                                     ! character sets (such as Japanese)
    CHARACTER(32) extendfontname     ! Any non-proportionally spaced font
                                     ! available on the system.
    INTEGER(4) extendfontsize        ! Takes same values as fontsize, but
                                     ! used for multiple-byte character sets
                                     ! when fontsize set to QWIN$EXTENDFONT.
    INTEGER(4) extendfontattributes  ! Font attributes such as bold and
                                     ! italic for multibyte character sets.
  END TYPE windowconfig

If you use SETWINDOWCONFIG to set the variables in windowconfig to -1, the highest resolution will be set for your system, given the other fields you specify, if any. You can set the actual size of the window by specifying parameters that influence the window size -- the number of x and y pixels, the number of rows and columns, and the font size. If you do not call SETWINDOWCONFIG, the window defaults to the best possible resolution and a font size of 8 by 16. The number of colors depends on the video driver used.

The font size, x pixels, y pixels, and columns and rows are related and cannot all be set arbitrarily. The following example specifies the number of x and y pixels and the font size and accepts the system calculation for the best number of rows and columns for the window:

    TYPE (windowconfig) wc
    LOGICAL status
  ! Set the x & y pixels to 800X600 and font size to 8x12.
    wc%numxpixels  = 800                ! pixels on x-axis, window width
    wc%numypixels  = 600                ! pixels on y-axis, window height
    wc%numtextcols = -1                 ! -1 requests system default/calculation
    wc%numtextrows = -1
    wc%numcolors   = -1
    wc%title       = " "C
    wc%fontsize    = #0008000C          ! Request 8x12 pixel fonts
    status         = SETWINDOWCONFIG(wc)

In this example:

  • The variables wc%numxpixels and wc%numypixels specify the size of the window, in this case 800 by 600 pixels. Within this window size, you can choose to specify either the font size (wc%fontsize) or the number of text columns (wc%numtextcols) and rows (wc%numtextrows).

    This example specifies the window size and font size, and lets the system calculate the number of text columns and rows.

    If you choose to specify the number of text columns and rows, you can let the system calculate (specify -1) either the font size or the window size.

  • The variable wc%fontsize is given as hexadecimal constant of #0008000C, which is interpreted in two parts:

    • The left side of 0008 (8) specifies the width of the font, in pixels.

    • The right side of 000C (12 in decimal) specifies the height of the font, in pixels.

  • The variable wc%numtextrows is -1 and wc%numtextcols is -1, which allows the system to calculate the best available number of text columns and text rows to be used, as follows:

    • The number of text columns is calculated as wc%numypixels (800) divided by the width of the font 8 (decimal) or 100.

    • The number of text rows is calculated as wc%numxpixels (600) divided by the width of the font, 12 (decimal) or 50.

The requested font size is matched to the nearest available font size. If the matched size differs from the requested size, the matched size is used to determine the number of columns and rows.

If scroll bars are needed (virtual window size exceeds the visible window size), because of the size required by horizontal and vertical scroll bars for a window, you may need to set the number of lines and columns to a value 1 or 2 greater than the number of rows and columns needed to display the application's information.

If the requested configuration cannot be set, SETWINDOWCONFIG returns .FALSE. and calculates parameter values that will work and best fit the requested configuration. Another call to SETWINDOWCONFIG establishes these values:

IF(.NOT.status) status = SETWINDOWCONFIG(wc)

For information on setting the graphics mode with SETWINDOWCONFIG, see Setting the Graphics Mode.

Routines such as SETWINDOWCONFIG work on the window that is currently in focus. You can have multiple windows open as your application requires, but you need to decide which one gains focus. There is a single frame window and one or more child windows. A window is in focus right after it is opened, after I/O to it, and when FOCUSQQ is used. Clicking the mouse when the cursor is in a window will also bring the window into focus.

For example, to set the characteristics for the window associated with unit 10, either gain focus with either an OPEN, a subsequent READ or WRITE statement to unit 10, or FOCUSQQ. For example, use OPEN:

open(unit=10, file='user')
  result = setwindowconfig(wc)

After you open unit 10, focus can be regained by a READ or WRITE statement to that unit. For example:

write(10,*) "Hello, this is unit 10"

Or you can use FOCUSQQ:

result = focusqq(10)
  result = setwindowconfig(wc)

For more information about when a window gains focus, see Giving a Window Focus and Setting the Active Window.