How to detect and “fix” DPI settings with Inno Setup?

后端 未结 3 956
粉色の甜心
粉色の甜心 2021-01-01 07:39

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 ar

相关标签:
3条回答
  • 2021-01-01 08:21

    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;
    
    0 讨论(0)
  • 2021-01-01 08:36

    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~

    0 讨论(0)
  • 2021-01-01 08:40

    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.

    0 讨论(0)
提交回复
热议问题