>local loForm >loForm = Newobject("myForm") >loForm.Show(1) >RETURN > >DEFINE CLASS myForm AS form > > > DoCreate = .T. > Name = "myForm" > > ADD OBJECT textbox1 AS textbox WITH ; > Value = "This is a test", ; > Height = 23, ; > Left = 8, ; > Top = 27, ; > Width = 100, ; > Name = "textbox1" > > > ADD OBJECT textbox2 AS textbox WITH ; > Value = "This is a test", ; > Height = 23, ; > Left = 8, ; > Top = 51, ; > Width = 100, ; > Name = "textbox2" > > > ADD OBJECT textbox3 AS textbox WITH ; > Value = "This is a test", ; > Height = 23, ; > Left = 8, ; > Top = 75, ; > Width = 100, ; > Name = "textbox3" > > > ADD OBJECT textbox4 AS textbox WITH ; > Value = "This is a test", ; > Height = 23, ; > Left = 8, ; > Top = 99, ; > Width = 100, ; > Name = "textbox4" > > > ADD OBJECT textbox5 AS textbox WITH ; > Value = "This is a test", ; > Height = 23, ; > Left = 8, ; > Top = 123, ; > Width = 100, ; > Name = "textbox5" > > > ADD OBJECT textbox6 AS textbox WITH ; > Value = "This is a test", ; > Height = 23, ; > Left = 8, ; > Top = 147, ; > Width = 100, ; > Name = "textbox6" > > > ADD OBJECT textbox7 AS textbox WITH ; > Value = "This is a test", ; > Height = 23, ; > Left = 8, ; > Top = 171, ; > Width = 100, ; > Name = "textbox7", ; > BorderStyle = 0 > > > ADD OBJECT textbox8 AS textbox WITH ; > Value = "This is a test", ; > Height = 23, ; > Left = 8, ; > Top = 195, ; > Width = 100, ; > Name = "textbox8" > > > PROCEDURE setTextboxWidth > lparameters toTextbox as TextBox > > local loLabel as Label, lnWidth as Integer, llLockScreen as Boolean > > thisform.AddObject('lblAux' + toTextbox.Name, 'Label') > > llLockScreen = thisform.LockScreen > thisform.LockScreen = .t. > with Getpem(thisform, 'lblAux' + toTextbox.Name) as Label > .Top = toTextBox.Top > .Left = 200 > .BorderStyle = toTextbox.BorderStyle > .Visible = .t. > .FontBold = toTextbox.FontBold > .FontItalic = toTextbox.FontItalic > .FontName = toTextbox.FontName > .FontSize = toTextbox.FontSize > .AutoSize = .t. > .Caption = toTextbox.Value > lnWidth = .Width + toTextbox.Margin * 2 + Iif(toTextbox.BorderStyle = 0, 0, 4) > endwith > thisform.LockScreen = llLockScreen > > *thisform.RemoveObject('lblAux' + toTextbox.Name) > > return lnWidth > ENDPROC > > > PROCEDURE Init > local lnTextbox, loTextbox, lnFonts, laFonts(1) > > > Rand(-1) > Afont(laFonts) > lnFonts = Alen(laFonts) > > for lnTextBox = 1 to 8 > loTextbox = Getpem(thisform, 'textbox' + Str(lnTextbox, 1)) > loTextbox.FontName = laFonts[Int(Rand() * lnFonts + 1)] > loTextbox.FontSize = 10 > next lnTextBox > ENDPROC > > > PROCEDURE textbox1.Refresh > this.Width = thisform.setTextboxWidth(this) > ENDPROC > > > PROCEDURE textbox2.Refresh > this.Width = thisform.setTextboxWidth(this) > ENDPROC > > > PROCEDURE textbox3.Refresh > this.Width = thisform.setTextboxWidth(this) > ENDPROC > > > PROCEDURE textbox4.Refresh > this.Width = thisform.setTextboxWidth(this) > ENDPROC > > > PROCEDURE textbox5.Refresh > this.Width = thisform.setTextboxWidth(this) > ENDPROC > > > PROCEDURE textbox6.Refresh > this.Width = thisform.setTextboxWidth(this) > ENDPROC > > > PROCEDURE textbox7.Refresh > this.Width = thisform.setTextboxWidth(this) > ENDPROC > > > PROCEDURE textbox8.Refresh > this.Width = thisform.setTextboxWidth(this) > ENDPROC > > >ENDDEFINE >