本文整理自网络,侵删。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TfrmMain = class(TForm)
btn800600: TButton;
btn640480: TButton;
procedure btn640480Click(Sender: TObject);
procedure btn800600Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
function DynamicResolution(X, Y: word): BOOL;
end;
var
frmMain: TfrmMain;
implementation
{$R *.dfm}
function TfrmMain.DynamicResolution(X, Y: word): BOOL;
var
lpDevMode: TDeviceMode;
begin
Result := EnumDisplaySettings(nil, 0, lpDevMode);
if Result then
begin
lpDevMode.dmFields := DM_PELSWIDTH Or DM_PELSHEIGHT;
lpDevMode.dmPelsWidth := X;
lpDevMode.dmPelsHeight := Y;
Result := ChangeDisplaySettings(lpDevMode, 0) = DISP_CHANGE_SUCCESSFUL;
end;
end;
procedure TfrmMain.btn640480Click(Sender: TObject);
begin
if DynamicResolution(640, 480) then
begin
ShowMessage('现在的分辨率是640*480');
end;
end;
procedure TfrmMain.btn800600Click(Sender: TObject);
begin
if DynamicResolution(800, 600) then
begin
ShowMessage('现在的分辨率是800*600');
end;
end;
相关阅读 >>
Delphi中文件名函数-路径、名称、子目录、驱动器、扩展名
Delphi 得到 winrar 处理解压缩文件的返回值 ?
关于Delphi xe5 firemonkey 手机屏幕自适应程序问题
Delphi 使用twebbrowser组件保存网页为html和mht文件
Delphi获取flash文件的影片时长,原始尺寸,帧数等信息
更多相关阅读请进入《Delphi》频道 >>