drawingarea question

Post

Posted
Rating:
#1 (In Topic #827)
Regular
bill-lancaster is in the usergroup ‘Regular’
Why is the DrawingArea1_Draw call executed several times?
A simple form with DrawingArea1 on it
and

Code

Public Sub DrawingArea1_Draw()
Draw.Text("XXXX",10,10,20,20)
End
is executed 5 times
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Guru
cogier is in the usergroup ‘Guru’
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.

Code (gambas)

  1. iCount As Integer
  2. DrawingArea1 As DrawingArea
  3. HBox1 As Hbox
  4. Label1 As Label
  5.  
  6. Public Sub Form_Open()
  7.  
  8.   With Me
  9.     .Arrangement = Arrange.Vertical
  10.     .H = 500
  11.     .W = 700
  12.     .Padding = 5
  13.  
  14.   With DrawingArea1 = New DrawingArea(Me) As "DrawingArea1"
  15.     .Expand = True
  16.  
  17.   With HBox1 = New HBox(Me)
  18.     .H = 56
  19.     .W = 100
  20.     .Invert = True
  21.  
  22.   With Label1 = New Label(HBox1) As "Label1"
  23.     .H = 56
  24.     .W = 100
  25.     .Expand = True
  26.     .Font.Bold = True
  27.     .Font.Size = 36
  28.     .Alignment = Align.Center
  29.  
  30.  
  31. Public Sub DrawingArea1_Draw()
  32.  
  33.   Inc iCount
  34.   Label1.Text = Str(iCount)
  35.   Paint.begin(DrawingArea1)
  36.   Paint.Text("XXXX", 10, 10, 20, 20)
  37.   Paint.Stroke
  38.   Paint.End
  39.  
  40.  
Online now: No Back to the top
1 guest and 0 members have just viewed this.