Code archives/Miscellaneous/How to tell if a window is FullScreen or not (Win32)

This code has been declared by its author to be Public Domain code.

Download source code

How to tell if a window is FullScreen or not (Win32) by col2012
This is a simple function to give a True or False return value if any window or App other than your one has gone fullscreen.

As an example, To capture the screen from a different App that is in FullScreen mode requires a slightly different process to getting the window handle compared to when that app is in normal window mode. So this function will let you know if any apps are in 'FullScreen mode'.

To use:-

IsFullScreen()

Simple eh.
Extern"Win32"
	Function EnumWindows(lpEnumProc:Byte Ptr,lParam Var) 'Customised for our purpose :-)
	Function GetSystemMetrics(nIndex)
EndExtern

Function IsFullScreen()
	Function IsTopMost(hWnd)
		Local info:WINDOWINFO = New WINDOWINFO
		GetWindowInfo(hWnd,info)
	
		If info.dwExStyle & WS_EX_TOPMOST Return True
	EndFunction
	
	Function IsFullScreenSize(hWnd,cx,cy)
		Local rect[4]
	
		GetWindowRect(hWnd,rect)
	
		Return (rect[2]-rect[0] = cx) And (rect[3]-rect[1] = cy)
	EndFunction
	
	Function IsFullScreenAndMaximized(hWnd)
		If IsTopMost(hWnd)
			Local cx = GetSystemMetrics(0) 'CM_CXSCREEN
			Local cy = GetSystemMetrics(1) 'CM_CYSCREEN
		
			If IsFullScreenSize(hWnd,cx,cy) Return True
		EndIf
	EndFunction

	Function EnumWindowProc(hWnd,lParam Var)"win32"
		If IsFullScreenAndMaximized(hWnd)
			lParam = True
			Return False
		EndIf
	
		Return True
	EndFunction
	
	Local FullScreenWindow
	EnumWindows(EnumWindowProc,FullScreenWindow)
	
	Return FullScreenWindow
EndFunction

Comments

None.

Code Archives Forum