Changing the Active Window

There may be times when you want to make a particular window active, or find out which window is currently active. Two functions control the program's focus (which window is active). The _wsetfocus function sets the focus and _wgetfocus function returns the file handle of the window with the current focus.

These routines are particularly useful when you want to bring a hidden or partially obscured window to the foreground.

For instance, this line makes a specific child window active:

iSuccess = _wsetfocus(wfilehandle(iChild[i]));

To verify that the focus changed correctly, test the return value. Both _wsetfocus and _wgetfocus return -1 if they fail.