[code=delphi]
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{函数}
function SetScreen(x,y: Word): Boolean;
var
DevMode: TDeviceMode;
begin
Result := EnumDisplaySettings(nil, 0, DevMode);
if Result then
begin
DevMode.dmFields := DM_PELSWIDTH or DM_PELSHEIGHT;
DevMode.dmPelsWidth := x;
DevMode.dmPelsHeight := y;
Result := ChangeDisplaySettings(DevMode, 0) = DISP_CHANGE_SUCCESSFUL;
end;
end;
{测试}
procedure TForm1.Button1Click(Sender: TObject);
begin
SetScreen(1280, 1024);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
SetScreen(1024, 768);
end;
end.
[/code]
转载请注明:鸟儿博客 » delphi之设置屏幕分辨率