QB64.com

QB64 is a modern extended BASIC programming language that retains QBasic/QuickBASIC 4.5 compatibility and compiles native binaries for Windows, Linux, and macOS.

The _SCREENMOVE statement positions the program window on the desktop using designated coordinates.

Syntax

_SCREENMOVE {column&, row&}

_SCREENMOVE _MIDDLE

Parameter(s)

Description

Example(s)

Calculating the border and header offsets by comparing a coordinate move with _MIDDLE by using trial and error.


userwidth& = _DESKTOPWIDTH: userheight& = _DESKTOPHEIGHT 'get current screen resolution
SCREEN _NEWIMAGE(800, 600, 256)
scrnwidth& = _WIDTH: scrnheight& = _HEIGHT  'get the dimensions of the program screen

_SCREENMOVE (userwidth& \ 2 - scrnwidth& \ 2) - 3, (userheight& \ 2 - scrnheight& \ 2) - 29
_DELAY 4
_SCREENMOVE _MIDDLE  'check centering

END 

When positioning the window, offset the position by -3 columns and - 29 rows to calculate the top left corner coordinate.

Moving a program window to a second monitor positioned to the right of the main desktop.


wide& = _DESKTOPWIDTH
high& = _DESKTOPHEIGHT

PRINT wide&; "X"; high&

_DELAY 4
_SCREENMOVE wide& + 200, 200 'positive value for right monitor 2

img2& = _SCREENIMAGE
wide2& = _WIDTH(img2&)
high2& = _HEIGHT(img2&)
PRINT wide2&; "X"; high2&
_DELAY 4
_SCREENMOVE _MIDDLE 'moves program back to main monitor 1 

Notes: Change the _SCREENMOVE column to negative for a left monitor.

_FULLSCREEN works in the primary monitor and may push all running programs to a monitor on the right.

See Also