Difference between revisions of "WINDOWHASFOCUS"

From QB64.org wiki
Jump to: navigation, search
(New keyword: _WINDOWHASFOCUS)
 
m (-)
 
Line 13: Line 13:
  
 
==Availability==
 
==Availability==
* '''Build 20170924/68'''
+
* '''Build 20170924/68'''.
  
  

Latest revision as of 12:30, 24 September 2017

The _WINDOWHASFOCUS function returns true (-1) if the current program's window has focus. Windows-only.


Syntax

hasFocus%% = _WINDOWHASFOCUS


Description

  • 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 Linux or macOS.


Availability

  • Build 20170924/68.


Examples

Example: Detecting if the current program has focus. Windows-only.

DO IF _WINDOWHASFOCUS THEN COLOR 15, 6 CLS PRINT "*** Hi there! ***" ELSE COLOR 0, 7 CLS PRINT "(ain't nobody looking...)" END IF _DISPLAY _LIMIT 30 LOOP

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.


See also



Navigation:
Go to Keyword Reference - Alphabetical
Go to Keyword Reference - By usage
Go to Main WIKI Page