Makes a QuickWin window the active (focused) window.
#include <io.h>
int _wsetfocus( int wfh );
wfh | File handle to a QuickWin window |
The _wsetfocus function makes a QuickWin window the active window (sets the program's focus to the window). 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 application has focus, the window gets focus. If not, the window will get the focus when the application gets focus.
If the program has other child windows, the focused window moves in front of them and is highlighted. This does not automatically direct I/O to the window. All I/O calls specify which window they are directed to by passing a stream pointer or file handle as an argument.
If successful, _wsetfocus returns 0. A return value of –1 indicates that the focus failed to change.
Standards:None
16-Bit:QWIN
32-Bit:None
_fwopen, _wabout, _wclose, _wgetexit, _wgetfocus, _wgetscreenbuf,
_wgetsize, _wmenuclick, _wopen, _wsetexit, _wsetscreenbuf, _wsetsize,
_wyield
/* WSETFOC.C - Demonstrate making a new QuickWin window the active
* window with _wsetfocus
*/
#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 */
wm = _wmenuclick( _WINTILE );
if( wm == -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 );
}