How to detect and “fix” DPI settings with Inno Set

2019-03-22 07:22发布

I created a setup with custom wizard pages and 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?

标签: inno-setup
3条回答
Anthone
2楼-- · 2019-03-22 07:53

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;
查看更多
Melony?
3楼-- · 2019-03-22 07:54

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~

查看更多
淡お忘
4楼-- · 2019-03-22 07:59

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.

查看更多
登录 后发表回答