Gets a file handle to the currently active QuickWin window.
#include <io.h>
int _wgetfocus( void );
The _wgetfocus function determines which of a QuickWin program's child (document) windows is active (has the program's “focus”). The routine returns the file handle of the active child window. If the entire application is not active, the routine returns the handle of the child window that would be active if the application were active. This routine is used only in QuickWin programs; it is not part of the Windows API. For full details about QuickWin, see Chapter 8 of Programming Techniques (in the Microsoft C/C++ version 7.0 documentation set).
If the active window is a closed child window kept on the screen with the _WINPERSIST flag (see _wclose), _wgetfocus fails.
If successful, _wgetfocus returns the file handle of the active child window. A return value of –1 indicates an error.
Standards:None
16-Bit:QWIN
32-Bit:None
_fwopen, _wabout, _wclose, _wgetexit, _wgetscreenbuf, _wgetsize, _wmenuclick, _wopen, _wsetexit, _wsetfocus, _wsetscreenbuf, _wsetsize, _wyield
/* WGETFOC.C - Demonstrate testing which QuickWin window is the
* active window with _wgetfocus
*/
#include <io.h>
#include <stdio.h>
#define NUMWINS 4 /* Number of windows */
#define OPENFLAGS "w" /* Access permission */
void main( void )
{
int i, nRes;
int sf, gf; /* Set/Get focus results */
FILE *wins[NUMWINS]; /* Array of file pointers */
/* Open NUMWINS windows */
/* NULL arguments accept default characteristics */
for( i = 0; i < NUMWINS; i++ )
{
wins[i] = _fwopen( NULL, NULL, OPENFLAGS );
if( wins[i] == NULL )
{
printf( "***ERROR: On _fwopen #%i\n", i );
exit( -1 );
}
/* Write in each window */
nRes = fprintf( wins[i], "Windows!\n" );
}
/* Tile child windows with _wmenuclick */
nRes = _wmenuclick( _WINTILE );
if( nRes == -1 )
{
printf( "***ERROR: _wmenuclick\n" );
exit( -1 );
}
/* Pass the focus from window to window */
for( i = 0; i < NUMWINS; i++ )
{
sf = _wsetfocus( _fileno( wins[i] ) );
gf = _wgetfocus();
if(( sf == -1 ) || ( gf == -1 )
|| ( gf != _fileno( wins[i] ) ) )
{
printf( "***ERROR: _wsetfocus/_wgetfocus\n" );
exit( -1 );
}
}
nRes = _fcloseall();
exit( 0 );
}