Scaling dialog based on TextHeight

Example scripts and tips (replaces Old Scripts & Tips archive)

Moderators: Dorian (MJT support), JRL, Phil Pendlebury

Post Reply
User avatar
Grovkillen
Automation Wizard
Posts: 940
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Scaling dialog based on TextHeight

Post by Grovkillen » Mon May 22, 2023 7:19 am

Code: Select all

Dialog>Dialog1
object Dialog1: TForm
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 200
  ClientWidth = 400
  TextHeight = 13
  object Label1: TLabel
    Left = 10
    Top = 45
    Width = 80
    Height = 20
    Caption = 'Label1'
    ParentFont = False
  end
  object MSButton1: tMSButton
    Left = 10
    Top = 10
    Width = 80
    Height = 25
    Caption = 'MSButton1'
    DoBrowse = False
    BrowseStyle = fbOpen
    ParentFont = False
  end
  object MSMemo1: tMSMemo
    Left = 100
    Top = 10
    Width = 180
    Height = 100
    Text = 'MSMemo1'
    ParentFont = False
  end
  object CheckBox1: TCheckBox
    Left = 300
    Top = 10
    Width = 100
    Height = 20
    Caption = 'CheckBox1'
    ParentFont = False
  end
end
EndDialog>Dialog1
Show>Dialog1,r
If you change the TextHeight to 10 instead of 13 the dialog will be bigger, change it to 20 (as an example) the dialog will be smaller. This is done by adding "ParentFont = False" to every element that you want to scale. The downside is that you cannot (at least I cannot) change the scale using the SetDialogProperty command.

Code: Select all

GetDialogProperty>Dialog1,,TextHeight,FOUND_TEXT_HEIGHT
//FOUND_TEXT_HEIGHT=NO_SUCH_PROPERTY
Let>ME=%Script%

Running: 15.0.23
version history

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts