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: 1048
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.24
version history

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

Re: Scaling dialog based on TextHeight

Post by Grovkillen » Thu Feb 22, 2024 12:43 pm

Is it possible to make the property accessible?

Code: Select all

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

Running: 15.0.24
version history

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1361
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Scaling dialog based on TextHeight

Post by Dorian (MJT support) » Thu Feb 22, 2024 2:25 pm

I have passed this on to dev.
Yes, we have a Custom Scripting Service. Message me or go here

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Scaling dialog based on TextHeight

Post by Marcus Tettmar » Thu Feb 22, 2024 3:10 pm

TextHeight is not actually a usable property - it's some kind of low level property used by the system for scaling but not actually usable or settable by the developer. It seems to be visible as a read only property which is why it's chucked out by the form designer, but you'll note if you edit the dialog that it doesn't show up in the property list. Reality is we should probably remove it completely from the output dialog definition.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

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

Re: Scaling dialog based on TextHeight

Post by Grovkillen » Thu Feb 22, 2024 4:11 pm

All right, thanks for the input Marcus. :)
Let>ME=%Script%

Running: 15.0.24
version history

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

Re: Scaling dialog based on TextHeight

Post by Grovkillen » Thu Feb 22, 2024 4:53 pm

But please don't remove it because I have some scripts that are still relying on it to exist :oops:
Let>ME=%Script%

Running: 15.0.24
version history

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

Re: Scaling dialog based on TextHeight

Post by Grovkillen » Sun Feb 25, 2024 8:05 pm

Okay, today I updated my scripts and uses another approach to get the scaling right. See this thread here: viewtopic.php?f=9&t=10828#p48757

I'm no longer using the TextHeight... 8)
Let>ME=%Script%

Running: 15.0.24
version history

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