Revision [21920]

This is an old revision of KeyPgScreencontrol made by fxm on 2017-09-25 13:50:56.



Sets or gets internal graphics library settings

declare sub ScreenControl ( byval what as long, byref param1 as integer = 0, byref param2 as integer = 0, byref param3 as integer = 0, byref param4 as integer = 0 )
declare sub ScreenControl ( byval what as long, byref param as string =
"" )

ScreenControl( what [, [ param1 ][, [ param2 ][, [ param3 ][, [ param4 ]]]]] )
ScreenControl( what [, param ] )

specifies the function to perform
optional first integer parameter, contains value to be set on entry or value got on exit
optional second integer parameter, contains value to be set on entry or value got on exit
optional third integer parameter, contains value to be set on entry or value got on exit
optional fourth integer parameter, contains value to be set on entry or value got on exit
optional string parameter, contains text to be set on entry or text got on exit

This function can be used to set or get internal GfxLib states. The what parameter specifies which operation to perform. On operations that set states, the param* parameters must contain the values to be set. On operations that get states, param* will hold the values returned by GfxLib when the function returns.
The meaning of the param* parameters depend on the what parameter, whose possible values are defined as constants in In lang fb, they are set to be stored in the FB Namespace.
Below is a list of the supported what constants - and their values as defined at time of writing - along with the parameters associated with them.

Supported operations

(*) denotes operations that are allowed while a graphics mode has not yet been set via Screen (Graphics) or ScreenRes,
for all other operations, return values are zero (0) or the empty string ("") and the operation has no effect if a graphics mode is not available at call time.

Get operations

'' include for some useful definitions
#include ""

'' use FB namespace for easy access to types/constants
Using FB

Dim e As EVENT
Dim As Integer x0, y0, x, y
Dim As Integer shakes = 0
Dim As Any Ptr img

ScreenRes 320, 200, 32
Print "Click to shake window"

'' find window coordinates
ScreenControl GET_WINDOW_POS, x0, y0


    If (shakes > 0) Then
        '' do a shake of the window

        If (shakes > 1) Then

            '' move window to a random position near its original coordinates
            x = x0 + Int(32 * (Rnd() - 0.5))
            y = y0 + Int(32 * (Rnd() - 0.5))
            ScreenControl SET_WINDOW_POS, x, y


            '' move window back to its original coordinates
            ScreenControl SET_WINDOW_POS, x0, y0

        End If

        shakes -= 1

    End If

    If (ScreenEvent(@e)) Then
        Select Case e.Type
        '' user pressed the mouse button

            If (shakes = 0) Then
                '' set to do 20 shakes
                shakes = 20

                '' find current window coordinates to shake around
                ScreenControl GET_WINDOW_POS, x0, y0
            End If

        '' user closed the window or pressed a key
            '' exit to end of program
            Exit Do

        End Select
    End If

    '' free up CPU for other programs
    Sleep 5


'' include for some useful definitions
#include ""

Dim As String driver

#ifdef __FB_WIN32__
'' set graphics driver to GDI (Win32 only), before calling ScreenRes

ScreenRes 640, 480

'' fetch graphics driver name and display it to user
ScreenControl FB.GET_DRIVER_NAME, driver
Print "Graphics driver name: " & driver

'' wait for a keypress before closing the window

Dialect Differences:
Differences from QB:
See also:
Back to Screen Functions
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki phatcode