unit UntAutoForm;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;//添加全局变量old_CXwidth:integer; //屏幕分辨率的宽
old_CYheight:integer; //屏幕分辨率的高
change_flag:boolean; //是否改变屏幕分辨率的设置
device_mode:TDevicemode; //设备的模式
implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);const
form_width=800;
form_height=600;
begin
change_flag:=false;
if ((screen.Width<>form_width)or(screen.Height<>form_height))
then if EnumDisplaySettings(nil,0,device_mode)then
begin
old_CXwidth:=GetSystemMetrics(SM_CXSCREEN);
old_CYheight:=GetSystemMetrics(SM_CYSCREEN);
change_flag:=true;
{改变设置}
device_mode.dmFields:=dm_pelswidth OR dm_pelsheight;
device_mode.dmPelsWidth:=form_width;//给宽度赋值
device_mode.dmPelsHeight:=form_height;//给高度赋值
ChangeDisplaySettings(device_mode,0); //改变设置
{修改成功,显示信息}
showmessage('设置成功!'+
'现在分辨率为:'+inttostr(form_width)+'*'+inttostr(form_height)
+'原分辨率为:'+inttostr(old_CXwidth)+'*'+inttostr(old_CYheight));
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if change_flag=true then
if EnumDisplaySettings(nil,0,device_mode) then
begin
{恢复设置}
device_mode.dmfields:=dm_pelswidth OR dm_pelsheight;
device_mode.dmPelsWidth:=old_CXwidth;
device_mode.dmPelsHeight:=old_CYheight;
ChangeDisplaySettings(device_mode,0);
{恢复成功,显示信息}
showmessage('恢复成功!'+
'现在分辨率为:'+inttostr(old_CXwidth)+'*'+inttostr(old_CYheight));
Close;// 关闭表单
end;
end;
end.我想知道带颜色的两个词的意思一样吗?不知该如何理解。大侠门快来看看吧
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;//添加全局变量old_CXwidth:integer; //屏幕分辨率的宽
old_CYheight:integer; //屏幕分辨率的高
change_flag:boolean; //是否改变屏幕分辨率的设置
device_mode:TDevicemode; //设备的模式
implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);const
form_width=800;
form_height=600;
begin
change_flag:=false;
if ((screen.Width<>form_width)or(screen.Height<>form_height))
then if EnumDisplaySettings(nil,0,device_mode)then
begin
old_CXwidth:=GetSystemMetrics(SM_CXSCREEN);
old_CYheight:=GetSystemMetrics(SM_CYSCREEN);
change_flag:=true;
{改变设置}
device_mode.dmFields:=dm_pelswidth OR dm_pelsheight;
device_mode.dmPelsWidth:=form_width;//给宽度赋值
device_mode.dmPelsHeight:=form_height;//给高度赋值
ChangeDisplaySettings(device_mode,0); //改变设置
{修改成功,显示信息}
showmessage('设置成功!'+
'现在分辨率为:'+inttostr(form_width)+'*'+inttostr(form_height)
+'原分辨率为:'+inttostr(old_CXwidth)+'*'+inttostr(old_CYheight));
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if change_flag=true then
if EnumDisplaySettings(nil,0,device_mode) then
begin
{恢复设置}
device_mode.dmfields:=dm_pelswidth OR dm_pelsheight;
device_mode.dmPelsWidth:=old_CXwidth;
device_mode.dmPelsHeight:=old_CYheight;
ChangeDisplaySettings(device_mode,0);
{恢复成功,显示信息}
showmessage('恢复成功!'+
'现在分辨率为:'+inttostr(old_CXwidth)+'*'+inttostr(old_CYheight));
Close;// 关闭表单
end;
end;
end.我想知道带颜色的两个词的意思一样吗?不知该如何理解。大侠门快来看看吧
http://baike.baidu.com/view/1080528.html