How to change the screen resolution in delphi? Here is the function maybe usefull
function NewRes(XRes, YRes: DWORD): Integer;
var
DevMode: TDeviceMode;
begin
EnumDisplaySettings(nil, 0, DevMode);
DevMode.dmFields := DM_PELSWIDTH or DM_PELSHEIGHT or
DM_DISPLAYFREQUENCY;
DevMode.dmPelsWidth := XRes;
DevMode.dmPelsHeight := YRes;
//DevMode.dmDisplayFrequency := Frequency;
Result := ChangeDisplaySettings(DevMode, 0);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
w:=Screen.Width;h:=Screen.Height;
if NewRes(800, 600) = DISP_CHANGE_SUCCESSFUL
then
ShowMessage('Resolution changed!');
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if NewRes(w, h) = DISP_CHANGE_SUCCESSFUL
then
ShowMessage('Resolution changed Back!');
end;
No comments:
Post a Comment