Display and Change video resolutions
To display available video modes, you must use the API function EnumDisplaySettings: it gets all display setting modes available.
To change modes, you must use ChangeDisplaySettings, that changes the video resolution and color depth.
procedure TForm1.FormCreate(Sender: TObject);
var
i : Integer;
DevMode : TDevMode;
begin
i:=0;
while EnumDisplaySettings(nil,i,DevMode) do begin
with Devmode do
ListBox1.Items.Add
(Format('%dx%d %d Colors',
[dmPelsWidth,dmPelsHeight,Int64(1) shl dmBitsperPel]));
Inc(i);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
DevMode : TDeviceMode;
liRetValue : Longint;
begin
if EnumDisplaySettings
(nil,Listbox1.ItemIndex,Devmode) then
liRetValue := ChangeDisplaySettings
(DevMode, CDS_UPDATEREGISTRY);
SendMessage(HWND_BROADCAST,
WM_DISPLAYCHANGE,
SPI_SETNONCLIENTMETRICS,
0);
end;

0 Comments:
Post a Comment
<< Home