Thread: DiskSpan GUI
View Single Post
  #3  
Old 17-08-2024, 03:21
Lord.Freddy's Avatar
Lord.Freddy Lord.Freddy is offline
Registered User
 
Join Date: Apr 2022
Location: ...
Posts: 54
Thanks: 222
Thanked 40 Times in 25 Posts
Lord.Freddy is on a distinguished road
Quote:
Originally Posted by Cesar82 View Post
Thanks for the support...
I've already tested something with custom scale but it doesn't work. It just makes DSG slower than if I use ScaleX and ScaleY to create all the forms.

It's not that.
The problem is that the DSG was the size of the screen and when applying the 150% scale, for example, it highlights the HEIGHT size of the monitor and is not drawn larger than the monitor's resolution.
The same happens with your script, see the attached video.
How about this?, This works perfectly for me.
Code:
#define DEBUG 0

[Setup]
AppName=SimpleForm
AppVerName=SimpleForm
CreateAppDir=no
OutputDir=.\
OutputBaseFilename=SimpleForm_CustomScale
[/Setup]

#Include AddBackslash(SourcePath) + "Module\ISSystemInfoModule.iss"

[_Code]
const
  DEFAULT_DPI = 96; // Default DPI (96 DPI is 100%)

function ScaleFontSize(Value: Integer): Integer;
var
  CurrentDPI: Integer;
begin
  CurrentDPI := GetDisplayVerticalDPI;
  Result := Round((((DEFAULT_DPI * 100) div CurrentDPI) * Value) div 100);
end;

function GetTextWidth(aText: String; aFont: TFont): Integer;
var
  Bmp: TBitmap;
begin
  Bmp := TBitmap.Create;
  try
    Bmp.Canvas.Font.Assign(aFont);
    Result := Bmp.Canvas.TextWidth(aText);
  finally
    Bmp.Free;
  end;
end;

function GetTextHeight(aText: String; aFont: TFont): Integer;
var
  Bmp: TBitmap;
begin
  Bmp := TBitmap.Create;
  try
    Bmp.Canvas.Font.Assign(aFont);
    Result := Bmp.Canvas.TextHeight(aText);
  finally
    Bmp.Free;
  end;
end;

function InitializeSetup: Boolean;
var
  SF: TSetupForm;
  SFP: TPanel;
begin
  SF := CreateCustomForm;
  with SF do
  begin
    ClientWidth := 1000;
    ClientHeight := 1350;
    Position := poDesktopCenter;
    Caption := 'CustomScale';
    BorderStyle := bsSingle;
    BorderIcons := [biSystemMenu, biMinimize];
    SFP := TPanel.Create(SF);
    with SFP do
    begin
      Parent := SF;
      Align := alClient;
      BevelInner := bvNone;
      BevelOuter := bvNone;
      Caption := 'Simple Form';
      Font.Style := [fsBold];
      Font.Size := ScaleFontSize(26);
      TabOrder := 0;
    end;
    with TLabel.Create(SF) do
    begin
      Parent := SFP;
      AutoSize := False;
      Caption := 'Simple Form';
      Font.Style := [fsBold];
      Font.Size := ScaleFontSize(99);
      Width := GetTextWidth(Caption, Font);
      Height := GetTextHeight(Caption, Font);
      Left := 10;
      Top := SF.ClientHeight - Height - Left;
      Transparent := False;
      Color := clYellow;      
    end;
    ShowModal;
  end;
  Result := False;
end;
[_/Code]

#if DEBUG
  #expr SaveToFile(AddBackslash(SourcePath) + "SimpleForm_PREPROCESSED.iss")
#endif
__________________
¤ Life good be a Dream ¤
Reply With Quote