Private observador1 As Observer
Public Sub Form_Open()
observador1 = New Observer(Button1) As "Observar1"
End
Public Sub Observar1_Rezise()
Print "Botón 1 cambia de tamaño"
End
Private Button1 As Button
Public Sub Form_Open()
With Button1 = New Button(Me) As "Button1"
.X = 100
.Y = 100
.W = 100
.H = 30
.AutoResize = True
.Text = "Aeneidos"
End With
End
Public Sub Button1_Click()
Dim c As Short
With Button1
.Text = "Tantaene animis caelestibus irae?"
c = .Font.TextWidth(.Text)
.Resize(c, .H)
End With
End
HBox1 As HBox
Label1 As Label
Button1 As Button
hSpring As Spring
iCount As Integer
Public Sub Form_Open()
With Me
.Height = 100
.Width = 375
.Padding = 5
.Arrangement = Arrange.Vertical
.Center
End With
With HBox1 = New HBox(Me)
.Height = 28
.Width = 100
End With
hSpring = New Spring(HBox1)
With Button1 = New Button(HBox1) As "Button1"
.Height = 28
.Text = "Uno"
.AutoResize = True
End With
hSpring = New Spring(HBox1)
hSpring = New Spring(Me)
With Label1 = New Label(Me) As "Label1"
.Height = 28
.AutoResize = True
.Alignment = Align.Center
.Text = "Button1.Width = " & Str(Button1.Width)
End With
End
Public Sub Button1_Click()
Dim sText As String[] = ["Uno", "Uno, Dos", "Uno, Dos, Tres", "Uno, Dos, Tres, Cuatro", "Uno, Dos, Tres, Cuatro, Cinco", "Uno, Dos, Tres, Cuatro, Cinco, Seis", "Uno, Dos, Tres, Cuatro, Cinco, Siete", "Uno, Dos, Tres, Cuatro, Cinco, Siete, Ocho", "Uno, Dos, Tres, Cuatro, Cinco, Siete, Ocho, Nueve", "Uno, Dos, Tres, Cuatro, Cinco, Siete, Ocho, Nueve, Diez"]
Inc iCount
Button1.Text = sText[iCount]
If iCount = sText.Max Then iCount = -1
Label1.Text = "Button.Width = " & Str(Button1.Width)
End
(27-09-2022, 14:22)Shell escribió: ¿ Hay una forma sencilla de solucionar este problema ?
.W = TextWidth(sText, Me.Font.Name, Me.Font.Size) + 7
'' 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
(27-09-2022, 15:39)vuott escribió: ...y de esta manera ?
'Dim c As Short
With Button1
.Text = "Tantaene animis caelestibus irae?"
' c = .Font.TextWidth(.Text)
' .Resize(c, .H)
End With
(27-09-2022, 20:46)Shell escribió: Ya que la propia propiedad Autoresize = True logra el mismo efecto.Sì, en efecto.
(27-09-2022, 22:31)vuott escribió: ...y no es mejor ? Màs breve, corto aquel modo ?