11

The question is simple. How to detect screen resolution change in Delphi ?

TLama
  • 75,147
  • 17
  • 214
  • 392
Dmitry
  • 14,306
  • 23
  • 105
  • 189

1 Answers1

22

You only need to detect the WM_DISPLAYCHANGE message.

For instance,

TForm1 = class(TForm)
private
protected
  procedure WMDisplayChange(var Message: TWMDisplayChange);
    message WM_DISPLAYCHANGE;
  { Private declarations }

public
  { Public declarations }
end;

...

procedure TForm1.WMDisplayChange(var Message: TWMDisplayChange);
begin
  ShowMessageFmt('The screen resolution has changed to %d×%d×%d.',
    [Message.Width, Message.Height, Message.BitsPerPixel]);
end;

Sample screenshot

Andreas Rejbrand
  • 105,602
  • 8
  • 282
  • 384