窗体大小怎么会随分辩率改变而改变??
在1024×768分辨率中,我设置窗长的heigth:=715 ,width:=1020;
但在800×600的辩率中,窗长的高和宽自动会改变!

解决方案 »

  1.   

    在程序启动的时候OnCreate事件中获取显示器的分辨率。
    1、使用Delphi的Screen全局变量来获的显示器的分辨率。
       if Screen.width = 1028 then
       if screen.width = 640 then2、使用WinAPI函数获取显示器分辩率。
      GetDeviceCaps(GetDC(Form1.Handle),HORZRES)
    Windows自身改变分辩率的时候应该有发出一个消息,请高手指点该消息名称。
      

  2.   

    //用这个过程,比如你要Form自动大小就: ForAutoSize(Form1,Screen.Width,Screen.Height);
    procedure FormAutoSize(AOwner: TComponent; ScreenWidth,
      ScreenHeigth: Integer);
    var
      OldFormWidth:integer;
    begin
      if screen.Width <> screenwidth then
      begin
        oldformwidth:=TForm(AOwner).Width;
        TForm(AOwner).Height:=longint(TForm(AOwner).Height) * longint(screen.height) div ScreenHeigth;
        TForm(AOwner).Width:=longint(TForm(AOwner).Width) * longint (screen.width) div screenwidth;
        TForm(AOwner).ScaleBy(screen.Width+5,screenwidth);
        TForm(AOwner).Font.Size:=(TForm(AOwner).Width div OldFormWidth) * TForm(AOwner).Font.Size;
      end;
    end;