unit fullscreen;

interface

uses
  Windows;

function SetFullscreenMode(width, height, color_depth : integer) : Boolean;
procedure RestoreDefaultMode;

var
  ScreenModeChanged : boolean;

implementation

function SetFullscreenMode(width, height, color_depth : integer) : Boolean;
var
  DeviceMode : TDevMode;
begin
with DeviceMode do
  begin
    dmSize := SizeOf(DeviceMode);
    dmBitsPerPel := color_depth;
    dmPelsWidth := width;
    dmPelsHeight := height;
    dmFields := DM_BITSPERPEL or DM_PELSWIDTH or DM_PELSHEIGHT;
    Result := ChangeDisplaySettings(DeviceMode,CDS_FULLSCREEN) = DISP_CHANGE_SUCCESSFUL;
    if Result then ScreenModeChanged := True;
    ScreenModeChanged := False;
  end;
end;

procedure RestoreDefaultMode;
var
DeviceMode : TDevMode absolute 0;
begin
ChangeDisplaySettings(DeviceMode, CDS_FULLSCREEN);
end;

end.
