花褪残红青杏小。燕子飞时,绿水人家绕。

delphi之设置屏幕分辨率

菜鸟编程 十五楼的鸟儿 28906浏览 0评论
关键是那个SetScreen函数
[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之设置屏幕分辨率

游客
发表我的评论 换个身份
取消评论

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址