■56589 / ) |
Re[2]: Application.Idleでゲームのタイマー制御 |
□投稿者/ YAS (15回)-(2011/01/20(Thu) 22:37:38)
|
具体的なコードは次のようになると思います。
なお,Timerをデザイナで配置するならばFormClosingのTimer1.Disposeはなくてもかまいません。
Public Class Form1
Dim WithEvents Timer1 As New Timer()
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Me.Timer1.Interval = 1000
Me.Timer1.Start()
End Sub
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Me.Timer1.Stop()
Me.Timer1.Dispose()
End Sub
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
Static StringValue As String = String.Empty
StringValue &= "○"
e.Graphics.DrawString(StringValue, Me.Font, Brushes.Black, 0, 0)
End Sub
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Me.Invalidate()
End Sub
End Class
|
|