procedure TForm1.FormCreate(Sender: TObject);
var
i : Integer;
DevMode : TDevMode;
begin
i:=0;
while EnumDisplaySettings(nil,i,DevMode) do begin
with Devmode do
ListBox1.Items.Add
(Format('%dx%d %d Colors',
[dmPelsWidth,dmPelsHeight,Int64(1) shl dmBitsperPel]));
Inc(i);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
DevMode : TDeviceMode;
liRetValue : Longint;
begin
if EnumDisplaySettings
(nil,Listbox1.ItemIndex,Devmode) then
liRetValue := ChangeDisplaySettings
(DevMode, CDS_UPDATEREGISTRY);
SendMessage(HWND_BROADCAST,
WM_DISPLAYCHANGE,
SPI_SETNONCLIENTMETRICS,
0);
end;
...
type
TForm1 = class(TForm)
ListBox1: TListBox;
...
private
procedure WMDisplayChange(var Message:TMessage);
message WM_DISPLAYCHANGE;
...
procedure
TForm1.WMDisplayChange(var Message: TMessage);
begin
ShowMessage('Changes in display detected!');
inherited;
end;