Help Center
Help CenterFreeBASIC

ScreenInfosub

Retrieves information about current video mode or the desktop.

Screen Functionssubdocumented

Syntax

Declare Sub ScreenInfo ( ByRef w As Long = 0, ByRef h As Long = 0, ByRef depth As Long = 0, ByRef bpp As Long = 0, ByRef pitch As Long = 0, ByRef rate As Long = 0, ByRef driver As String = "" )
Declare Sub ScreenInfo ( ByRef w As LongInt, ByRef h As LongInt, ByRef depth As LongInt = 0, ByRef bpp As LongInt = 0, ByRef pitch As LongInt = 0, ByRef rate As LongInt = 0, ByRef driver As String = "" )

Parameters

NameDescription
wWidth.
hHeight.
depthColor depth in bits.
bppBytes per pixel.
pitchBytes per scan line.
rateRefresh rate.
driverDriver name.

Description


This function can be useful to get current mode informations like graphics driver name, color depth, screen size and more.

If ScreenInfo is called when no graphics mode is set, it returns the information about the desktop.

Here's a description of available fields:

wWidth of the screen in pixels
hHeight of the screen in pixels
depthCurrent pixel format bits per pixel: this can be 1, 2, 4, 8, 16, or 32
bppBytes per pixel
pitchSize of a framebuffer row in bytes
rateCurrent refresh rate, or 0 if unknown
driverName of current graphics driver in use, like DirectX (Direct2D added on new systems) or X11


Remarks

Usage


in the LONG (or INTEGER<32>) version of the sub:
ScreenInfo [ w ] [, [ h ] [, [ depth ] [, [ bpp ] [, [ pitch ] [, [ rate ] [, driver ]]]]]]
in the LONGINT (or INTEGER<64>) version of the sub:
ScreenInfo w , h [, [ depth ] [, [ bpp ] [, [ pitch ] [, [ rate ] [, driver ]]]]]

Version


  • Before fbc 1.08.0:
Syntax:
Declare Sub ScreenInfo ( ByRef w As Integer = 0, ByRef h As Integer = 0, ByRef depth As Integer = 0, ByRef bpp As Integer = 0, ByRef pitch As Integer = 0, ByRef rate As Integer = 0, ByRef driver As String = "" )
Usage:
ScreenInfo [ w ] [, [ h ] [, [ depth ] [ , [ bpp ] [ , [ pitch ] [ , [ rate ] [, driver ]]]]]]

Dialect Differences


  • Not available in the -lang qb dialect unless referenced with the alias __Screeninfo.

Differences from QB


  • New to FreeBASIC

See also


Example


Dim w As Long, h As Long

Dim depth As Long

Dim driver_name As String



Screen 15, 32 

' Obtain info about current mode 

ScreenInfo w, h, depth,,,,driver_name

Print Str(w) + "x" + Str(h) + "x" + Str(depth); 

Print " using " + driver_name + " driver" 

Sleep 

' Quit graphics mode and obtain info about desktop 

Screen 0 

ScreenInfo w, h, depth 

Print "Desktop running at " + Str(w) + "x" + Str(h) + "x" + Str(depth);

Reference

  • Documented in KeyPgScreeninfo.html