11

问题很简单。如何检测 Delphi 中的屏幕分辨率变化?

4

1 回答 1

20

您只需要检测WM_DISPLAYCHANGE消息。

例如,

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;

示例截图

于 2013-02-08T12:29:59.980 回答