TO wolf_cyj,hhycqrm:
您們的方法我想應該可行的! 不過可能要作小小調整. 參考您們的做法, 我作了小小調整, 請指教:
unit test;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs;
Const
MySetWidth = 800;
MySetHeight = 600;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
方法一:
procedure TForm1.FormCreate(Sender: TObject);
begin
Scaled := True;
if (Screen.Width<>MySetWidth) then
begin
Height := longint(Height)*longint(Screen.height) div MySetHeight;
Width := longint(Width) * longint(Screen.Width) div MySetWidth;
ScaleBy(Screen.Width, MySetWidth);
end;
end;
方法二:
procedure TForm1.FormCreate(Sender: TObject);
var
devmode: tDevicemode;
begin
if Screen.Width <> MySetWidth then
begin
if EnumDisplaySettings(nil,0,devmode) then
begin
devmode.dmFields := DM_PELSWIDTH or DM_PELSHEIGHT;
devmode.dmPelsWidth := MySetWidth;
// 寬度
devmode.dmPelsHeight := MySetHeight;
// 高度
ChangeDisplaySettings(devmode,0);
// 更改設置
end;
end;
end;
end.
這兩种方法雖然都可以改變屏幕的在小, 但始終不能解決其刷新率的問題.