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

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

Giving a Window Focus and Setting the Active Window

When a window is made active, it receives graphics output (from ARC, LINETO, and OUTGTEXT, for example) but is not brought to the foreground and thus does not have the focus. When a window acquires focus, either by a mouse click, I/O to it, or by a FOCUSQQ call, it also becomes the active window. When a window gains focus, the window that previously had focus will lose focus.

If a window needs to be brought to the foreground, it must be given focus. The window that has the focus is always on top, and all other windows have their title bars grayed out. A window can have the focus and yet not be active and not have graphics output directed to it. Graphical output is independent of focus.

Under most circumstances, focus and active should apply to the same window. This is the default behavior of QuickWin and a programmer must consciously override this default.

Certain QuickWin routines (such as GETCHARQQ, PASSDIRKEYSQQ, and SETWINDOWCONFIG) that do not take a unit number as an input argument usually affect the active window whether or not it is in focus.

If another window is made active but is not in focus, these routines affect the window active at the time of the routine call. This may appear unusual to the user since a GETCHARQQ under these circumstances will expect input from a grayed, background window. The user would then have to click on that window before input could be typed to it.

To use these routines (that effect the active window), either do I/O to the unit number of the window you wish to put in focus (and also make active), or call FOCUSQQ (with a unit number specified). If only one window is open, then that window is the one affected. If several windows are opened, then the last one opened is the one affected since that window will get focus and active as a side effect of being opened.

The OPEN (IOFOCUS) parameter also can determine whether a window receives the focus when a I/O statement is executed on that unit. For example:

  OPEN (UNIT = 10, FILE = 'USER', IOFOCUS = .TRUE.)

With an explicit OPEN with FILE='USER', IOFOCUS defaults to .TRUE. For child windows opened implicitly (no OPEN statement before the READ, WRITE, or PRINT) as unit 0, 5, or 6, IOFOCUS defaults to .FALSE..

If IOFOCUS=.TRUE., the child window receives focus prior to each READ, WRITE, or PRINT. Calls to OUTTEXT or graphics functions (for example, OUTGTEXT, LINETO, and ELLIPSE) do not cause the focus to shift. If you use IOFOCUS with any unit other than a QuickWin child window, a run-time error occurs.

The focus shifts to a window when it is given the focus with FOCUSQQ, when it is selected by a mouse click, or when an I/O operation other than a graphics operation is performed on it, unless the window was opened with IOFOCUS=.FALSE.. INQFOCUSQQ determines which unit has the focus. For example:

    USE IFQWIN
   INTEGER status, focusunit
   OPEN(UNIT = 10, FILE = 'USER', TITLE = 'Child Window 1')
   OPEN(UNIT = 11, FILE = 'USER', TITLE = 'Child Window 2')
 ! Give focus to Child Window 2 by writing to it:
   WRITE (11, *) 'Giving focus to Child 2.'
 ! Give focus to Child Window 1 with the FOCUSQQ function:
   status = FOCUSQQ(10)
    ...
 ! Find out the unit number of the child window that currently has focus:
   status = INQFOCUSQQ(focusunit)

SETACTIVEQQ makes a child window active without bringing it to the foreground. GETACTIVEQQ returns the unit number of the currently active child window. GETHWNDQQ converts the unit number into a Windows handle for functions that require it.