TGC Codebase Backup



Automatically set Program to Highest Resolution by Code Dragon

11th Aug 2007 16:49
Summary

Make your DBPro programs automatically detect the user's screen resolution.



Description

This code demonstrates how to automatically detect the screen size of the user's monitor. No more "do you want to run this in 800x600 or 1280x1024 mode?" messages!

Note: Must be compiled in 640x480 Windowed Fullscreen for best effect. The program will then automatically switch to ????x???? Fullscreen Exclusive mode.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    #constant User32 = 1

sync on
sync rate 0

load dll "User32.dll", User32

width = call dll(User32, "GetSystemMetrics", 0)
height = call dll(User32, "GetSystemMetrics", 1)
depth = 32

set window off
set display mode width, height, depth, 1

make object cube 1, 1

do
  text 0, 0, "Automatically detected a " + str$(width) + "x" + str$(height) + " screen"
  yrotate object 1, object angle y(1) + 1
  sync
loop