Mengubah Resolusi Layar


Tips & Trik Delphi, Tips Belajar Delphi, Belajar Delphi Online
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
function SetScreenResolution(Width, Height: integer): Longint;
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
OldWidth, OldHeight: integer;

implementation

{$R *.DFM}

function
TForm1.SetScreenResolution(Width, Height: integer): Longint;
var
DeviceMode: TDeviceMode;
begin
with DeviceMode do
begin
dmSize := SizeOf(TDeviceMode);
dmPelsWidth := Width;
dmPelsHeight := Height;
dmFields := DM_PELSWIDTH or DM_PELSHEIGHT;
end;
Result := ChangeDisplaySettings(DeviceMode, CDS_UPDATEREGISTRY);
end;

procedure
TForm1.Button1Click(Sender: TObject);
begin
SetScreenResolution(640, 480);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin

//resolusi semula
SetScreenResolution(OldWidth, OldHeight);
end;

procedure
TForm1.FormCreate(Sender: TObject);
begin
OldWidth := GetSystemMetrics(SM_CXSCREEN);
OldHeight := GetSystemMetrics(SM_CYSCREEN);
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
SetScreenResolution(800, 600);
end;


procedure
TForm1.Button4Click(Sender: TObject);
begin
SetScreenResolution(1024, 768);
end;

end.

TransCODE Software

Tinggalkan Balasan

Please log in using one of these methods to post your comment:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s