Ciao ragazzi, vorrei animare un disegno.
Io uso il seguente codice per disegnare in una "label" ma non mi sembra molto efficiente, voi come fareste?
In pratica vorrei che il disegno appaia nella label in seguito ad un click in una label fino a quando non lo fermo con il bottone.codice:Private Sub cmdMove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdMove.Click If cmdMove.Text = "ferma" Then cmdMove.Text = "muovi" ferma = True Else cmdMove.Text = "ferma" ferma = False Dim G As Graphics = Graphics.FromHwnd(lab.Handle) G.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias Draw(G) End If End Sub Public Sub Draw(ByVal G As Graphics) Dim i As Int16 Do While Not ferma i += 1 G.Clear(lab.BackColor) G.DrawRectangle(Pens.Black, New Rectangle(i, 0, 10, 10)) Thread.Sleep(3) Application.DoEvents() Loop End sub
Grazie.

Rispondi quotando