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.我想知道带颜色的两个词的意思一样吗?不知该如何理解。大侠门快来看看吧

解决方案 »

  1.   

    http://tech.ddvip.com/2008-11/122655593392184.html
      

  2.   

    感谢这位大侠,不过我还可以问一下,就是说这两方法都可以使用了,他们没什么冲突或特别的用途?我还想问一下EnumDisplaySettiongs()的Eunm是什么意思?
      

  3.   

    看到API让我想起一件事,大侠,那个DELPHI6。0 HELP怎么也搜不到我想要函数,似乎他任何函都不能搜,我还下了一个中文帮助,几乎一样,也许我不会用吧。能否赐教??
      

  4.   

    EnumDisplaySettings和GetSystemMetrics都是api函数
      

  5.   

    api函数可以在ISAPI帮助文档中找到,这个帮助文件也在delphi的帮助目录下
      

  6.   


    http://baike.baidu.com/view/1080528.html
      

  7.   

    我又想起一件事,我下的中文帮助是一个object pascal references好像与我想要的Delphi里的帮助不一样哦,,而且不可以查询API和class,反正死活是查不出来的,这个东西与Delphi有什么不同之处吗,我怎么才可以用上它啊?