[Gambas-user] Label control

Martin mbelmonte at belmotek.net
Wed Jun 15 09:13:28 CEST 2022


El 15/6/22 a las 0:26, Steve via User escribió:
> Is there a way to detect when the text Will overflow the control so that 
> I can split the text up properly to display?
Hi,
I suggest this function to know the size in pixels, then wit this 
information you decide what to do.

'' Returns the value in pixels of a text string, regarding the typography

Public Function TextWidth(str As String, sFont As String, zSize As 
Integer) As Integer

   Dim fnt As New Font

   fnt.Name = sFont
   fnt.Size = zSize

   Return fnt.TextWidth(str)

End

Then in form use some like this.

       If Object.Type(o) = "CheckBox" Then
         o.W = dsk.TextWidth(o.Text, Me.Font.Name, Me.Font.Size) + 32
       Endif

Best regards.


More information about the User mailing list