Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect screen resolution change in Delphi?

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

like image 241
Dmitry Avatar asked Feb 08 '13 12:02

Dmitry


1 Answers

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

like image 155
Andreas Rejbrand Avatar answered Oct 15 '22 05:10

Andreas Rejbrand