Page 1 of 1
drawingarea question
Posted: Sunday 27th February 2022 6:02pm
by bill-lancaster
Why is the DrawingArea1_Draw call executed several times?
A simple form with DrawingArea1 on it
and
Code: Select all
Public Sub DrawingArea1_Draw()
Draw.Text("XXXX",10,10,20,20)
End
is executed 5 times
Re: drawingarea question
Posted: Monday 28th February 2022 3:25pm
by cogier
Very interesting. I am not sure why, but it drops to 3 if you use Paint instead of draw (
now depricated).
Try this code and then resize the Form. It will be in the hundreds in no time.
Sorry, I don't know why this happens, I can only guess this is due to the Form arranging its items.
iCount As Integer
DrawingArea1 As DrawingArea
HBox1 As Hbox
Label1 As Label
Public Sub Form_Open()
With Me
.Arrangement = Arrange.Vertical
.H = 500
.W = 700
.Padding = 5
End With
With DrawingArea1 = New DrawingArea(Me) As "DrawingArea1"
.Expand = True
End With
With HBox1 = New HBox(Me)
.H = 56
.W = 100
.Invert = True
End With
With Label1 = New Label(HBox1) As "Label1"
.H = 56
.W = 100
.Expand = True
.Font.Bold = True
.Font.Size = 36
.Alignment = Align.Center
End With
End
Public Sub DrawingArea1_Draw()
Inc iCount
Label1.Text = Str(iCount)
Paint.begin(DrawingArea1)
Paint.Text("XXXX", 10, 10, 20, 20)
Paint.Stroke
Paint.End
End