1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| procedure TForm1.Button1Click(Sender: TObject);
var
lpDisplayDevice: TDisplayDevice;
dwFlags,cc: DWORD;
DC : THandle; // Display context
Bits : Integer; // Bits per pixel
HRes : Integer; // Horizontal resolution
VRes : Integer; // Vertical resolution
DM : TDevMode; // To Save EnumDisplaySettings
ModeNum : LongInt; // Video Mode Number
Ok : Bool;
tsl : tstringlist ;
s : string ;
begin
// list display devices
lpdisplaydevice.cb := sizeof(lpdisplaydevice);
dwflags := 0;
cc:= 0;
while EnumDisplayDevices(nil, cc, lpDisplayDevice , dwFlags) do
begin inc(cc); showmessage(lpdisplaydevice.DeviceString); end;
tsl:=tstringlist.create ;
// Get current video mode
DC := Canvas.Handle;
Bits := GetDeviceCaps(DC, BITSPIXEL);
HRes := GetDeviceCaps(DC, HORZRES);
VRes := GetDeviceCaps(DC, VERTRES);
tsl.add('Current video mode :'+Format('%d bits, %d x %d',[Bits, HRes, VRes]));
// Show all modes available (i.e. supported by the driver)
ModeNum := 0; // The 1st one
EnumDisplaySettings(Nil, ModeNum, DM);
tsl.add('Available mode :'+Format('%d bits, %d x %d',[DM.dmBitsPerPel, DM.dmPelsWidth, DM.dmPelsHeight]));
Ok := True;
While Ok do begin
Inc(ModeNum); // Get next one
OK := EnumDisplaySettings(Nil, ModeNum, DM);
if OK then s:='Available mode :'+Format('%d bits, %d x %d',[DM.dmBitsPerPel, DM.dmPelsWidth, DM.dmPelsHeight]) ;
if tsl.indexof(s)<0 then tsl.Add(s) ;
end;
showmessage(tsl.Text) ;
tsl.Free ;
end; |
Partager