监视系统分辩率
unit Unit1;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_width:integer; //用于保存为改变设置前的屏幕分辨率宽
  old_height:integer; //用于保存为改变设置前的屏幕分辨率高
  changeflag:boolean; //用于表明是否改变了屏幕设置
  device_mode:tDevicemode; //用于表明设备模式
implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
const
  form_width=800;
  form_height=600;
begin
  {初始化改变标志}
  changeflag:=false;
   {判断分辨率,若不一致,则改变屏幕分辨率}
   if (screen.Width<>form_width)or(screen.Height<>form_Height)then
     if EnumDisplaySettings(nil,0,device_mode)then
       begin
         old_width:=GetSystemMetrics(SM_CXSCREEN);
         old_height:=GetSystemMetrics(SM_CYSCREEN);
         changeflag:=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_width)+'*'+inttostr(old_height));
       end;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
  {判断是否改变,是,则恢复设置}
  if changeflag=true then
  if EnumDisplaySettings(nil,0,device_mode)then
     begin
     {恢复设置}
     device_mode.dmFields:=dm_pelswidth OR dm_pelsheight;
     device_mode.dmPelsWidth:=old_width; //赋原来设置的宽度
     device_mode.dmPelsHeight:=old_height; //赋原来设置的高度
     ChangeDisplaySettings(device_mode,0); //恢复设置
     end;
  showmessage('恢复设置成功,设置:'+inttostr(old_width)+'*'+inttostr(old_height));
close;
end;end.

解决方案 »

  1.   

    字体比较麻烦,其它的倒简单;如果你是1024*768的;
    在 OnShow里写;
      Scaleby( Screen.Width,1024);
      width := width * screen.width div 1024;
      height := height * screen.height div 768;
      

  2.   

    用Form的Scaled、PixelsPerInch、Position等属性试试看。
      

  3.   

    procedure Tform1.FormCreate(Sender: TObject);
    var
      x, y: LongInt;
     
      i: integer;
    begin
      form1.scaled := true;
      //窗体可以缩放
      x := getSystemMetrics(SM_CXSCREEN);
      y := getSystemMetrics(SM_CYSCREEN);
      //程序运行时获取目标机器的屏幕分辨率
      if (x <> ScreenHeight) or (y <> ScreenWidth) then
      //目标机器的屏幕分辨率与作者机器的屏幕分辨率不同
        begin
           form1.height:=form1.height*x DIV ScreenHeight;
           form1.width:=form1.width*y DIV ScreenWidth;
           scaleBy(x,ScreenHeight);
           //调用窗体的scaleBy函数,将窗体大小变为初始大小的x/ ScreenHeight倍。
           //这是本程序的关键技巧,同时缩放的包括窗体上各组件和字体。
        end;     for i:=5 downto 0 do
          begin
           dbgrid1.Columns[i].Width:=y*dbgrid1.Columns[i].Width div 600 ;
           dbgrid1.Columns[i].font.size:=y*dbgrid1.Columns[i].Font.Size div 600;
           dbgrid1.Columns[i].title.Font.size:=y*dbgrid1.Columns[i].title.font.Size div 600;
          end;end;
      

  4.   

    我看还是有改变显示器分辨率,以前我做作
    用API,或者找个控件.特简单!