Change the screen resolution (video mode)  

Send By: Santy_Concepción
Web : N.A.
Email: SANTYCG@teleline.es
Date: 01/02/00

Tip accessed 450 times

 


With this function we will be able to change the resolution (video mode) of the screen.
If the driver of your card allows it, the change will be made without having that to restart the computer.
The function returns the result from the call to the function of the API ChangeDisplaySettings that it can be one of these values:


 DISP_CHANGE_SUCCESSFUL	The settings change was successful.
 DISP_CHANGE_RESTART		The computer must be restarted in order for the graphics mode to work.
 DISP_CHANGE_BADFLAGS		An invalid set of flags was passed in.
 DISP_CHANGE_FAILED		The display driver failed the specified graphics mode.
 DISP_CHANGE_BADMODE		The graphics mode is not supported.
 DISP_CHANGE_NOTUPDATED	Windows NT only: Unable to write settings to the registry.



Here there is the example:


 procedure TForm1.Button1Click(Sender: TObject);

   function NuevaRes(XRes, YRes: DWord):integer;
   var
     lpDevMode : TDeviceMode;
   begin
       EnumDisplaySettings(nil, 0, lpDevMode);
       lpDevMode.dmFields:=DM_PELSWIDTH or DM_PELSHEIGHT;
       lpDevMode.dmPelsWidth:=XRes;
       lpDevMode.dmPelsHeight:=YRes;
       NuevaRes:=ChangeDisplaySettings(lpDevMode, 0);
   end;

 begin
   NuevaRes(800,600);
 end;