[Help] Deleting drawn graphics

Posts 1–9 of 9 · Page 1 of 1
[Help] Deleting drawn graphics
Hey guys, I'm using this code to draw an ellipse at the point the cursor is currently at.

[php]
Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove

Dim myGraphics As Graphics


myGraphics = Graphics.FromHwnd(ActiveForm().Handle)

myGraphics.DrawEllipse(pen:=New Pen(Color.Green), _
rect:=New Rectangle(x:=(e.X - 35), y:=(e.Y - 35), Width:=70, Height:=70))

myGraphics.Dispose()


End Sub
[/php]

However, I need it to first delete the previously drawn graphic from the form before drawing then next one as this is the effect im currently getting.



But what I want is just for a circle to follow the pointer wherever it goes.

Help?
i guess you can just clear the whole form.

(Event mouse move)
Clear all (xx.Clear(color) if not wrong..)
Draw new circle

Code:
Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove

        Dim myGraphics As Graphics


        myGraphics = Graphics.FromHwnd(ActiveForm().Handle)

        myGraphics.Clear(Color.Green)

        myGraphics.DrawEllipse(pen:=New Pen(Color.Green), _
        rect:=New Rectangle(x:=(e.X - 35), y:=(e.Y - 35), Width:=70, Height:=70))

        myGraphics.Dispose()


    End Sub
like this or so.. not quite sure since i dont code in Vb.
That just makes the form go completely green O.o
Quote Originally Posted by Jason View Post
That just makes the form go completely green O.o
ups.. Color.White (form color) <.< or W/e ur form color is.
Quote Originally Posted by 'Bruno View Post
ups.. Color.White (form color) <.< or W/e ur form color is.
Brilliant, thanks a lot (i used "Me.BackColor")
Quote Originally Posted by Jason View Post
Brilliant, thanks a lot (i used "Me.BackColor")
even better p
why you have it on mouse move??
change it to mouse down and mouse up
Quote Originally Posted by ViittO View Post
why you have it on mouse move??
change it to mouse down and mouse up
what the hell.. dude. maybe because he doesnt want an event click? he just want it to get it draw around his mouse.
Quote Originally Posted by 'Bruno View Post
what the hell.. dude. maybe because he doesnt want an event click? he just want it to get it draw around his mouse.
Exactly. I'm doing a basic shooting game so I need to draw the crosshair at cursor as it moves.
Posts 1–9 of 9 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us