Title: Change the Screen Resolution?
{
ThefunctionNewRescanhavethefollowingresult:
DISP_CHANGE_SUCCESSFUL Thesettingschangewassuccessful.
DISP_CHANGE_RESTART Thecomputermustberestartedinorderforthegraphicsmodetowork.
DISP_CHANGE_BADFLAGS Aninvalidsetofflagswaspassedin.
DISP_CHANGE_FAILED Thedisplaydriverfailedthespecifiedgraphicsmode.
DISP_CHANGE_BADMODE Thegraphicsmodeisnotsupported.
DISP_CHANGE_NOTUPDATED WindowsNTonly:Unabletowritesettingstotheregistry.
}
{
FolgeneRckgabewertesindfrNewResmglich:
DISP_CHANGE_SUCCESSFUL Auflsunggendert
DISP_CHANGE_RESTART Computermussneugestartetwerden
DISP_CHANGE_BADFLAGS FalscheFlags
DISP_CHANGE_FAILED FehlerinGrafiktreiber
DISP_CHANGE_BADMODE Auflsungnichtuntersttzt
DISP_CHANGE_NOTUPDATED WindowsNT:EinstellungenkonntennichtindieRegistrygeschriebenwerden
}
functionNewRes(XRes,YRes:DWORD;Frequency:Cardinal):Integer;
var
DevMode:TDeviceMode;
begin
EnumDisplaySettings(nil,0,DevMode);
DevMode.dmFields:=DM_PELSWIDTHorDM_PELSHEIGHTorDM_DISPLAYFREQUENCY;
DevMode.dmPelsWidth:=XRes;
DevMode.dmPelsHeight:=YRes;
DevMode.dmDisplayFrequency:=Frequency;
Result:=ChangeDisplaySettings(DevMode,0);
end;
procedureTForm1.Button1Click(Sender:TObject);
begin
ifNewRes(1280,1024,85)=DISP_CHANGE_SUCCESSFULthen
ShowMessage('Resolutionchanged!');
end
//Anotherfunction:
functionChangeResolution(XResolution,YResolution,Depth:DWORD):BOOL;
var
DevMode:TDeviceMode;
i:Integer;
begin
Result:=False;
i:=0;
whileEnumDisplaySettings(nil,i,DevMode)do
withDevModedo
begin
if(dmPelsWidth=XResolution)and
(dmPelsHeight=YResolution)and
(dmBitsPerPel=Depth)then
ifChangeDisplaySettings(DevMode,CDS_UPDATEREGISTRY)=
DISP_CHANGE_SUCCESSFULthen
begin
Result:=True;
SendMessage(HWND_BROADCAST,WM_DISPLAYCHANGE,SPI_SETNONCLIENTMETRICS,0);
Break;
end;
Inc(i);
end;
end;
procedureTForm1.Button1Click(Sender:TObject);
begin
ifChangeResolution(800,600,32)thenShowMessage('Resolutionchanged!');
end;