Wednesday, November 28, 2007

Rosolution Adjust In Delphi

Another to change resolution in delphi, I used to apply is the following

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: