请问在delphi里怎样改变显示器的刷新率(10分)

  • 主题发起人 主题发起人 Rico888
  • 开始时间 开始时间
R

Rico888

Unregistered / Unconfirmed
GUEST, unregistred user!
请问在delphi里怎样改变显示器的刷新率
 
使用windows API解决吧!EnumDisplaySettings()和ChangeDisplaySettings()。
 
procedure TForm1.ChangeSreenDisplay(x, y: Integer);
var
lpDevMode : TDeviceMode;
begin
EnumDisplaySettings(nil, 0, lpDevMode);
lpDevMode.dmFields:=DM_PELSWIDTH or DM_PELSHEIGHT or DM_DISPLAYFREQUENCY;
lpDevMode.dmPelsWidth:=x;
lpDevMode.dmPelsHeight:=y;
lpDevMode.dmDisplayFlags:=DM_DISPLAYFREQUENCY;
lpDevMode.dmDisplayFrequency:=85; //刷新频率
ChangeDisplaySettings(lpDevMode, CDS_UPDATEREGISTRY);
end;

procedure TForm1.screen1Click(Sender: TObject);
begin
ChangeSreenDisplay(800,600);
end;

那么简单,,给分
 
function IsSupportDM(Width, Height, Bits, Freq: Cardinal): Boolean;
var
i: Integer;
dm: TDeviceMode;

begin
Result:=False;
i:=0;

while EnumDisplaySettings(Nil,i,dm) do
begin
with dm do
begin
if (dmPelsWidth=Width) and (dmPelsHeight=Height) and (dmBitsPerPel=Bits) and (dmDisplayFrequency=Freq) then
begin
Result:=True;
break;
end;
end;
Inc(i);
end;
end;

function SetDisplaySettings(Width,Height,Bits,Freq: Integer): Boolean;
var
dm: TDeviceMode;
begin
Result:=False;

if not IsSupportDM(Width,Height,Bits,Freq) then
begin
MsgBox(Format('您的显示器不支持 %dX%dX%dX%d 模式! ',[Width,Height,Bits,Freq]));
Exit;
end;

EnumDisplaySettings(nil, 0, dm);
with dm do
begin
dmFields:=DM_PELSWIDTH or DM_PELSHEIGHT or DM_BITSPERPEL or DM_DISPLAYFREQUENCY;
dmPelsWidth:=Width;
dmPelsHeight:=Height;
dmBitsPerPel:=Bits;
dmDisplayFrequency:=Freq;
end;
ChangeDisplaySettings(dm, CDS_UPDATEREGISTRY);

Result:=True;
end;

 
或是这个也行!
function ChangeScreenSize(Width, Height, Frequency, BitsPerpel : Integer) : Boolean;
var
DevMode : TDevMode;
begin
Result := True;
with DevMode do
begin
dmPelsWidth := Width; // 屏幕宽度
dmPelsHeight := Height; // 屏幕高度
dmDisplayFrequency := Frequency; // 刷新频率
dmBitsPerpel := BitsPerpel; // 颜色深度,例如:16, 24, 32
try
ChangeDisplaySettings(DevMode, 0);
except
Result := False;
end;
end;
end;
 
后退
顶部