// Test all screen resolutions to see if the desired res can be obtained
// Colours is the desired colour depth in Bits.
function CanDisplayAt(Width, Height, Colours: Cardinal): boolean;
var i: integer;
devmode: TDevMode;
begin
i := 0;
Result := false;
while enumdisplaysettings(nil,i,devmode) do
begin
with devmode do
if (dmpelswidth = Width) and (dmpelsheight = Height) and (dmbitsperpel = Colours) then
begin
result := True;
exit;
end;
inc(i);
end;
end;
// Colours is the desired colour depth in Bits.
function ChangeResolution(Width, Height, Colours: Cardinal): boolean;
var ScreenData: TDevMode;
begin
if EnumDisplaySettings(nil, 1, ScreenData) then
begin
with screendata do
begin
dmPelsWidth := Width;
dmPelsHeight := Height;
dmBitsPerPel := Colours;
dmFields := dmFields or DM_PELSWIDTH;
dmFields := dmFields or DM_PELSHEIGHT;
dmfields:= dmFields or DM_BITSPERPEL;
end;
end;
if ChangeDisplaySettings(ScreenData, 0) = DISP_CHANGE_SUCCESSFUL then
result := true
else
result := false;
//SendMessage(HWND_BROADCAST,WM_DISPLAYCHANGE,SPI_SETNONCLIENTMETRICS,0);
end;