https://lists.gambas-basic.org/pipermail/user/2023-December/081024.html
Su quest'argomento proponiamo ai lettori del nostro forum la lettura di questa pagina della Wiki:
https://www.gambas-it.org/wiki/index.php/Adattare_la_dimensione_di_un_Oggetto_grafico_al_testo_contenuto
Forse c'è già negli esempi che hai citato della nostra wiki, ma io sfrutterei il controllo TextLabel e i contenitori che ci offre gambas, mi sono divertito a fare questo:
Public Sub Form_Open()
Dim hHBox As HBox
Dim hVBox As VBox
Dim hTextLabel As TextLabel
Dim oPanel As Panel
Dim hLabel As Label
With Me
.Arrangement = Arrange.Vertical
.Margin = True
End With
With hHBox = New HBox(Me)
.AutoResize = True
.Background = Color.SoftMagenta
End With
With hVBox = New VBox(hHBox)
.Background = Color.SoftRoyal
.AutoResize = True
.Width = 100
End With
With hTextLabel = New TextLabel(hVBox)
.AutoResize = True
.Foreground = Color.Royal
.Width = hVBox.Width
.Text = "Sono un testo veramente lungo per poter stare entro i miei confini (100 px), ciò nonostante ottengo lo spazio necessario in altezza"
End With
With oPanel = New Panel(Me)
.Expand = True
.Arrangement = Arrange.Fill
End With
With hLabel = New Label(oPanel)
.Alignment = Align.Center
.Background = Color.SoftYellow
.Foreground = Color.LightBackground
.Text = "SONO UN PANEL\nCON PROPRIETÀ\nEXPAND = TRUE"
.Font.Size = 16
.Font.Bold = True
End With
End
Lo so c'è un po tanta fuffa, ma come dicevano i Latini...
:ciao: