LiveCode LessonsHow To - LiveCode Sample Scripts User InterfaceCheck whether the screen resolution is high enough

Check whether the screen resolution is high enough

This lesson demonstrates how to check whether the screen resolution of the user's system is high enough for your app.

The checkForScreenSize command

This command allows you to check the screen size of a machine. You might call it in a stack's startup or preOpenStack handler to check the screen dimensions and adjust your app layout or display a message to the user in the screen size is too small.

on preOpenStack

checkForScreenSize

end preOpenStack

This handler is simple, taking no parameters. It checks the last two items of the screenRect function, the width and height of the main screen. If the main screen is smaller than 1024x768 pixels, in either dimension, it quits the application after displaying a dialog box with an explanation.

This example quits the application if the specified condition isn't met. Of course, you should use such a handler only if your application actually requires a screen of this size. If the application does not actually require this screen size, but does work better with a large screen, it's better to display a dialog box but not quit the program, in case the user prefers to continue with the lower resolution (or has a screen that can't be used at high resolution).

The checkForScreenSize command code

on checkForScreenSize

if item 3 of the screenRect < 1024 or item 4 of the screenRect < 768 then

answer error "This app requires a 1024x768 or larger screen." with "Sorry"

quit

end if

end checkForScreenSize

Checking for other requirements

You can write a similar handler to check for any condition that your application requires. For example, here is a variation to use if your application requires QuickTime 7.0 or higher to be installed:

on checkForQuickTime

if the QTVersion < 7.0 then

answer "SuperApp requires QuickTime 7.0." with "Sorry"

quit

end if

end checkForQuickTime

0 Comments

Add your comment

E-Mail me when someone replies to this comment