Faceți căutări pe acest blog

vineri, 8 septembrie 2017

Correlation between Margin and Fontsize

Some VFP objects, like textbox, editbox or spinner, have a property named Margin.
I discovered that the maximum meaningful value of this property is correlated to the value of fontsize property, and is influenced by the fontname property.

Let say Fontname = "Arial"
If Fontsize = 9, most probably Margin = 15 is the maximum value, all above this would make no difference, i.e. Margin = 18 or Margin = 27 will have the same effect like Margin = 15.
If Fontsize = 16, most probably Margin = 23 is the maximum value, all above this would make no difference, i.e. Margin = 33 or Margin = 50 will have the same effect like Margin = 23.
If Fontsize = 24, most probably Margin = 37 is the maximum value, all above this would make no difference, i.e. Margin = 45 or Margin = 72 will have the same effect like Margin = 37.

Slightly different values, but not too much, can be found on different fonts (experienced with Garamond instead of Arial)

**************************************************
 PUBLIC ofrm
ofrm = CREATEOBJECT("form1")
ofrm.show()

**************************************************
DEFINE CLASS form1 AS form


    Top = 0
    Left = 14
    Height = 250
    Width = 1306
    DoCreate = .T.
    Caption = "Form1"
    Name = "Form1"


    ADD OBJECT text1 AS textbox WITH ;
        FontName = "Courier New", ;
        FontSize = 4, ;
        Value = "Test", ;
        Height = 193, ;
        Left = 36, ;
        Top = 24, ;
        Width = 217, ;
        Name = "Text1"


    ADD OBJECT edit1 AS editbox WITH ;
        FontName = "Courier New", ;
        FontSize = 4, ;
        Height = 193, ;
        Left = 312, ;
        Top = 24, ;
        Width = 289, ;
        Value = "Test", ;
        Name = "Edit1"


    ADD OBJECT label1 AS label WITH Left = 660, Caption = "Margin"
    ADD OBJECT spinner1 AS spinner WITH ;
        FontName = "Courier New", ;
        FontSize = 4, ;
        Height = 192, ;
        Left = 660, ;
        Top = 24, ;
        Width = 252, ;
        Name = "Spinner1"


    ADD OBJECT label2 AS label WITH Left = 972, Caption = "Fontsize"
    ADD OBJECT spinner2 AS spinner WITH ;
        Height = 192, ;
        Left = 972, ;
        Top = 24, ;
        Width = 252, ;
        Value = 4, ;
        Name = "Spinner2"


    PROCEDURE spinner1.InteractiveChange
        STORE This.Value TO This.Margin,ThisForm.text1.Margin,ThisForm.edit1.margin
    ENDPROC


    PROCEDURE spinner2.InteractiveChange
        STORE This.Value TO ThisForm.Spinner1.FontSize,ThisForm.text1.FontSize,ThisForm.edit1.FontSize
    ENDPROC


ENDDEFINE
*
*-- EndDefine: form1
**************************************************

Related posts
http://praisachion.blogspot.com/2017/09/correlation-between-margin-and-fontsize.html
http://praisachion.blogspot.com/2017/08/invalid-keys-in-treeview-control.htm

Niciun comentariu:

Trimiteți un comentariu