SCREENMOVE: Difference between revisions

From QB64 Phoenix Edition Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(4 intermediate revisions by the same user not shown)
Line 7: Line 7:




{{Parameters}}
{{PageParameters}}
* Positions the program window on the desktop using the {{Parameter|column&}} and {{Parameter|row&}} pixel coordinates for the upper left corner.
* Positions the program window on the desktop using the {{Parameter|column&}} and {{Parameter|row&}} pixel coordinates for the upper left corner.
* '''_MIDDLE''' can be used instead to automatically center the program window on the desktop, in any screen resolution.
* '''_MIDDLE''' can be used instead to automatically center the program window on the desktop, in any screen resolution.
Line 13: Line 13:


{{PageDescription}}
{{PageDescription}}
* The program's [[SCREEN]] dimensions may influence the desktop position that can be used to keep the entire window on the screen.  
* The program's [[SCREEN]] dimensions may influence the desktop position that can be used to keep the entire window on the screen.
* Use [[_DESKTOPWIDTH]] and [[_DESKTOPHEIGHT]] to find the current desktop resolution to place the program's window.
* Use [[_DESKTOPWIDTH]] and [[_DESKTOPHEIGHT]] to find the current desktop resolution to place the program's window.
* On dual monitors a negative {{Parameter|column&}} position or a value greater than the main screen width can be used to position a window in another monitor.
* On dual monitors a negative {{Parameter|column&}} position or a value greater than the main screen width can be used to position a window in another monitor.
* '''A small delay may be necessary when a program first starts up to properly orient the screen on the desktop properly.''' See [[_SCREENEXISTS]].
* '''A small delay may be necessary when a program first starts up to properly orient the screen on the desktop properly.''' See [[_SCREENEXISTS]].
* '''[[Keywords_currently_not_supported_by_QB64#Keywords_not_supported_in_Linux_or_macOS_versions|Keyword not supported in Linux versions]]'''
* '''[[Keywords currently not supported by QB64#Keywords_not_supported_in_Linux_or_macOS_versions|Keyword not supported in Linux versions]]'''
 
 
{{PageAvailability}}
<!-- QB64 = a version or none, QBPE = a version or all, Platforms = yes or no -->
<gallery widths="48px" heights="48px" mode="nolines">
File:Qb64.png|'''v0.926'''
File:Qbpe.png|'''all'''
File:Apix.png
File:Win.png|'''yes'''
File:Lnx.png|'''no'''
File:Osx.png|'''yes'''
</gallery>
<!-- additional availability notes go below here -->




Line 31: Line 44:
{{Cl|_SCREENMOVE}} _MIDDLE  'check centering
{{Cl|_SCREENMOVE}} _MIDDLE  'check centering


{{Cl|END}} '' ''
{{Cl|END}}
{{CodeEnd}}
{{CodeEnd}}
: When positioning the window, offset the position by -3 columns and - 29 rows to calculate the top left corner coordinate.
: When positioning the window, offset the position by -3 columns and - 29 rows to calculate the top left corner coordinate.
Line 51: Line 64:
{{Cl|PRINT}} wide2&; "X"; high2&
{{Cl|PRINT}} wide2&; "X"; high2&
{{Cl|_DELAY}} 4
{{Cl|_DELAY}} 4
{{Cl|_SCREENMOVE}} {{Cl|_SCREENMOVE|_MIDDLE}} 'moves program back to main monitor 1 '' ''
{{Cl|_SCREENMOVE}} {{Cl|_SCREENMOVE|_MIDDLE}} 'moves program back to main monitor 1
{{CodeEnd}}
{{CodeEnd}}
: ''Notes:'' Change the [[_SCREENMOVE]] column to negative for a left monitor.
: ''Notes:'' Change the [[_SCREENMOVE]] column to negative for a left monitor.
Line 63: Line 76:
* [[_SCREENPRINT]]
* [[_SCREENPRINT]]
* [[_SCREENEXISTS]]
* [[_SCREENEXISTS]]
* [[_NEWIMAGE]], [[SCREEN (statement)]]
* [[_NEWIMAGE]], [[SCREEN]]
 




{{PageNavigation}}
{{PageNavigation}}

Latest revision as of 00:34, 5 February 2023

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


Syntax

_SCREENMOVE {column&, row&|_MIDDLE}


Parameters

  • Positions the program window on the desktop using the column& and row& pixel coordinates for the upper left corner.
  • _MIDDLE can be used instead to automatically center the program window on the desktop, in any screen resolution.


Description

  • The program's SCREEN dimensions may influence the desktop position that can be used to keep the entire window on the screen.
  • Use _DESKTOPWIDTH and _DESKTOPHEIGHT to find the current desktop resolution to place the program's window.
  • On dual monitors a negative column& position or a value greater than the main screen width can be used to position a window in another monitor.
  • A small delay may be necessary when a program first starts up to properly orient the screen on the desktop properly. See _SCREENEXISTS.
  • Keyword not supported in Linux versions


Availability


Examples

Example 1: 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.


Example 2: 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



Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link