How to detect and "fix" DPI settings with Inno Setup?
I created a setup with custom wizard pages and开发者_如何学C custom background images. The problem is with non-standard DPI systems.
When I run this setup the background images are not properly showing. How can I detect the DPI size and use custom settings for wizard pages?
The "most correct" way is to have alternative images for small and larger fonts mode. The "slightly less correct" method is to pad the background so it shows that instead of shrinking. The "very wrong" method is to try and adjust the form layout/size to suit.
You can detect the DPI size using the TGraphicsObject.PixelsPerInch
property and load a different image.
Deanna mentioned that the DPI can be detected like so:
You can detect the DPI size using the
TGraphicsObject.PixelsPerInch
property and load a different image.
However, the InnoSetup documentation suggests that TGraphicsObject
has no PixelsPerInch
attribute, it is instead an attribute of TFont
objects.
The DPI can therefore be detected and custom settings be implemented using code similar to this:
procedure CheckDPI;
var
CurrentDPI, StandardDPI, MediumDPI, LargeDPI: Integer;
begin
{ Get the current DPI }
CurrentDPI := WizardForm.Font.PixelsPerInch;
{ Store defaults determined from Windows DPI settings }
StandardDPI := 96; { 100% }
MediumDPI := 120; { 125% }
LargeDPI := 144; { 150% }
if (CurrentDPI >= StandardDPI) and (CurrentDPI < MediumDPI) then
begin
{ Execute some custom code for small to medium DPI }
end
else if (CurrentDPI >= MediumDPI) and (CurrentDPI < LargeDPI) then
begin
{ Execute some custom code for medium to large DPI }
end
else if (CurrentDPI >= LargeDPI) then
begin
{ Execute some custom code for large DPI or above }
end;
end;
Define the following functions by yourself to cheat Inno Setup:
function ScaleX(Value: Integer): Integer;
begin
Result := Value;
end;
function ScaleY(Value: Integer): Integer;
begin
Result := Value;
end;
Bing GO~
精彩评论