Making a Child Window Active

When the user selects a document window with the mouse or the keyboard, the selected window is highlighted and appears in front of all other windows if windows are cascaded, or is simply highlighted if windows are tiled. The selected window has input focus and is called the active window.

To make a document window the active window (to bring it to the front), call the _wsetfocus function.

For example, before writing to one of several cascaded windows, you can bring the target window to the top with _wsetfocus and then write to it, as shown by the following code:

/* Check result, then write to the window */

result = _wsetfocus( fileno( fp ) );

You can also learn whether a child window has the focus by calling the _wgetfocus function.

The _wsetfocus function returns 0 if successful or –1 if not. The _wgetfocus
function returns an integer handle to the window with the focus if successful, or
–1 if not.

See QWDEMO.C for further examples.