Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How can I change the screen resolution? Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
21-May-03
Category
System
Language
Delphi 3.x
Views
119
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Ernesto De Spirito 

How can I change the screen resolution?

Answer:

To change the screen resolution you can use the following function which is a 
wrapper for the Windows API ChangeDisplaySettings. The function takes the desired 
width and height as parameters and returns 
the return value of ChangeDisplaySettings (see the documentation for more datails). 
1   
2   function SetScreenResolution(Width, Height: integer): Longint;
3   var
4     DeviceMode: TDeviceMode;
5   begin
6     with DeviceMode do
7     begin
8       dmSize := SizeOf(TDeviceMode);
9       dmPelsWidth := Width;
10      dmPelsHeight := Height;
11      dmFields := DM_PELSWIDTH or DM_PELSHEIGHT;
12    end;
13    Result := ChangeDisplaySettings(DeviceMode, CDS_UPDATEREGISTRY);
14  end;


You can use ChangeDisplaySettings to change other properties of the display like 
the color depth and the display frequency. 

Sample call 

In the following example first we get the current screen resolution before setting 
it to 800x600, and then we restore it calling SetScreenResolution again. 

15  var
16    OldWidth, OldHeight: integer;
17  
18  procedure TForm1.Button1Click(Sender: TObject);
19  begin
20    OldWidth := GetSystemMetrics(SM_CXSCREEN);
21    OldHeight := GetSystemMetrics(SM_CYSCREEN);
22    SetScreenResolution(800, 600);
23  end;
24  
25  procedure TForm1.Button2Click(Sender: TObject);
26  begin
27    SetScreenResolution(OldWidth, OldHeight);
28  end;


Copyright (c) 2001 Ernesto De Spiritomailto:edspirito@latiumsoftware.com
Visit: http://www.latiumsoftware.com/delphi-newsletter.php

			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC