|
-
Jul 8th, 2015, 02:02 PM
#1
Thread Starter
Addicted Member
Form Paint Does Not Work
Hello! I was working on a screen saver that creates rectangles that start from the center of the screen and expand as they move to the edge of the screen. It was working just fine for a little while, and I'm not sure what I did but now, when I load the form, nothing appears. Can someone please help? Thank you!
vb Code:
Public Class Form1
Dim R As New Random
Dim R1 As New Rectangle
Dim Cs As New Size
Dim Distance As New Decimal
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Me.DoubleBuffered = True
NewRectangle()
Timer1.Start()
End Sub
Private Sub NewRectangle()
Distance = 0
Cs = ClientSize
R1.Width = R.Next((Cs.Width * 0.1), (Cs.Width * 0.5))
R1.X = R.Next(-2 * Cs.Width, Cs.Width)
R1.Height = R.Next((Cs.Height * 0.1), (Cs.Height * 0.5))
R1.Y = R.Next((Cs.Height * 0.1), (Cs.Height * 0.5))
End Sub
Private Sub Form1_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs)
e.Graphics.FillRectangle(Brushes.Blue, New Rectangle((R1.X * Distance + Cs.Width * 0.5), (R1.Y * Distance + Cs.Height * 0.5), (R1.Width * Distance), (R1.Height * Distance)))
End Sub
Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
Distance = (Distance + 0.1)
If Distance > 2 Then
Distance = 0
NewRectangle()
End If
Me.Invalidate()
End Sub
End Class
-
Jul 8th, 2015, 02:15 PM
#2
Re: Form Paint Does Not Work
You're missing the Handles clause:
Code:
Private Sub Form1_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs) Handles Form1.Paint
This happens when you cut and paste code.
-
Jul 8th, 2015, 04:55 PM
#3
Thread Starter
Addicted Member
Re: Form Paint Does Not Work
Thank you! I actually did cut and paste some code, and I did not realize some of it was changed. Thanks again.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|