问题很简单。如何检测Delphi中的屏幕分辨率变化?
答案 0 :(得分:19)
您只需要检测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;
Sample screenshot http://privat.rejbrand.se/screenreschange.png