The question is simple. How to detect screen resolution change in Delphi ?
Asked
Active
Viewed 4,350 times
11
-
Look a message having something to do with system metrics. E.g. WM_SYSTEMMETRICSCHANGE – iMan Biglari Feb 08 '13 at 12:29
-
1possible duplicate of [How to recognize when number, position, or resolution of monitors has changed?](http://stackoverflow.com/questions/11004051/how-to-recognize-when-number-position-or-resolution-of-monitors-has-changed) – David Heffernan Feb 08 '13 at 17:38
-
@David - That one is now marked duplicate of this one (wonder what happens if they recurse..). – Sertac Akyuz Feb 08 '13 at 20:04
-
1@David, Sertac: The other one has been closed, so this one should *not* be closed. Also, I think it is good that the old one is closed and not this one, since this one has a better answer. – Andreas Rejbrand Feb 08 '13 at 20:09
-
I agree. The diamond mod Shog got it right. – David Heffernan Feb 08 '13 at 20:13
-
2Being the OP of the other question, I do have to say this one does have a better answer, and by the same person. – Jerry Dodge Feb 09 '13 at 03:22
-
1Duplicates are very useful to find the answer by any search string. – Dmitry Feb 09 '13 at 07:29
1 Answers
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;

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