Tuesday, March 1, 2011

Quick way to retrieve current screen resolution

Why use the Windows API when you can retrieve the current screen resolution using two simple variables?

 
Screen.Width
Screen.Height
Listing #1 : Delphi code. Download scrsize (0.16 KB).
 
Above variables will automatically get updated if the screen resolution were to change while the application is running.
 
MessageDlg(
  'screen width = ' + IntToStr( Screen.Width ) +
  ', screen height = ' + IntToStr( Screen.Height ),
  mtInformation, [mbOk], 0 );
Listing #2 : Delphi code. Download sample (0.23 KB).

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Kang Iwan K-sev | Thank's for your visit To My Site - Ridwan Mulyana | Cibeureum