Howdy. I want a program to run at 1600x900 on desktops and 1280x720 or 1280x800 on laptops. That seems straightforward enough, but this sub - at the big resolution so far - doesn't actually center the program window on the desktop. Why is _SCREENMOVE _MIDDLE opening this window far to the right and off-screen? Also any suggestions for improving this resolution changing sub will be gladly and humbly accepted. Thanks! Ted
' ------------------------------------------------------------------------------
SUB resolution () ' first attempt at resolution changer
' I want 1600x900 on larger screens else 1280x720 or 1280x800 on smaller
DIM ratio AS SINGLE
IF _DESKTOPWIDTH > 1750 THEN SWIDTH = 1600 ELSE SWIDTH = 1280
ratio = _DESKTOPWIDTH / _DESKTOPHEIGHT
IF ratio = 1.6 THEN ' 8:5 aspect ratio - 13" macBook
SHEIGHT = SWIDTH / ratio
ELSE SHEIGHT = SWIDTH / 1.777 ' 16:9 aspect ratio
END IF
CLS
PRINT "Screen Width is"; SWIDTH
PRINT "Screen Height is"; SHEIGHT
PRINT "Aspect Ratio is"; ratio;
_DELAY 3
SCREEN _NEWIMAGE(SWIDTH, SHEIGHT, 32)
IF SWIDTH = 1280 THEN ' laptop mode in fullscreen
_FULLSCREEN , _SMOOTH
IF _FULLSCREEN = 0 THEN ' on fullscreen error
BEEP: CLS
_FULLSCREEN _OFF
PRINT "Fullscreen failed. Going native. Press a key."
SLEEP
_SCREENMOVE _MIDDLE
END IF
END IF
IF SWIDTH = 1600 THEN _SCREENMOVE _MIDDLE ' I put this here after the SCREEN statement, but it still doesn't center the program window
CenterX = SWIDTH / 2 ' define screen center points
CenterY = SHEIGHT / 2 '
END SUB
' ----------------------------------------------------------------------
' ------------------------------------------------------------------------------
SUB resolution () ' first attempt at resolution changer
' I want 1600x900 on larger screens else 1280x720 or 1280x800 on smaller
DIM ratio AS SINGLE
IF _DESKTOPWIDTH > 1750 THEN SWIDTH = 1600 ELSE SWIDTH = 1280
ratio = _DESKTOPWIDTH / _DESKTOPHEIGHT
IF ratio = 1.6 THEN ' 8:5 aspect ratio - 13" macBook
SHEIGHT = SWIDTH / ratio
ELSE SHEIGHT = SWIDTH / 1.777 ' 16:9 aspect ratio
END IF
CLS
PRINT "Screen Width is"; SWIDTH
PRINT "Screen Height is"; SHEIGHT
PRINT "Aspect Ratio is"; ratio;
_DELAY 3
SCREEN _NEWIMAGE(SWIDTH, SHEIGHT, 32)
IF SWIDTH = 1280 THEN ' laptop mode in fullscreen
_FULLSCREEN , _SMOOTH
IF _FULLSCREEN = 0 THEN ' on fullscreen error
BEEP: CLS
_FULLSCREEN _OFF
PRINT "Fullscreen failed. Going native. Press a key."
SLEEP
_SCREENMOVE _MIDDLE
END IF
END IF
IF SWIDTH = 1600 THEN _SCREENMOVE _MIDDLE ' I put this here after the SCREEN statement, but it still doesn't center the program window
CenterX = SWIDTH / 2 ' define screen center points
CenterY = SHEIGHT / 2 '
END SUB
' ----------------------------------------------------------------------