From QB64 Wiki
Revision as of 14:54, 30 December 2017 by SMcNeill
The _WINDOWHASFOCUS function returns true (-1) if the current program's window has focus.
- hasFocus%% = _WINDOWHASFOCUS
- The function returns true (-1) if the current program is the topmost window on the user's desktop and has focus. If the current program is running behind another window, the function returns false (0).
- Not available in MacOS (but is available in Linux, see availability below).
- A window is normally defocused by clicking on another window, but Linux environments can be configured to only require the mouse be moved over another window. This should not affect your use of _WINDOWHASFOCUS.
- Build 20170924/68 (Windows)
- Build 20171230/83 (Linux)
Example: Detecting if the current program has focus.
- Explanation: The program will display "*** Hi There! ***" while the window is the topmost and is being manipulated by the user. If another window, the taskbar or the desktop are clicked, the program window loses focus and the message "(ain't nobody looking...)" is displayed.