capture freeform using mousemove

gilgamesh

New member
Joined
Apr 28, 2004
Messages
3
Hi,
Thanks for your time. I have written a program that captures mouse move and draws the movement of the mouse onto a Image on the form (like the microsoft paint - freeform drawing using the pencil). Currently, I grab the mouse coordinates and draw a line just one pixel long. However, if the movement is fast it doesnt seem to grab all coordinates. There are large gaps between two points. Is there any other way in .NET to solve this problem. My code:

Code:
Dim gr As Graphics
  Dim pen1 As New Pen(Color.Red, 1)

 Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Panel1.AutoScroll = True
    gr = PictureBox1.CreateGraphics
  End Sub

  Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
   
    If e.Button = MouseButtons.Left Then
      gr.DrawLine(pen1, e.X, e.Y, e.X + 1, e.Y +1)
    End If

  End Sub


Thanks again,
Regards,
V
 
I dont know if this works, but its an idea that came across my mind.
Instead of using the mousemove event use a timer and make it tick fast, really fast. Place the code that draws in this timer. Then use a variable to control when the mouse draws and when it doesnt

something like this

Private Sub timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timer1.Tick
If drawing then
draw here
End If
End Sub

now drawing is a boolean variable which is true when the user presses the mouse button and false when he leaves the mouse....
 
Back
Top