473,320 Members | 1,694 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Drawing lines with dots leaves spaces if mouse moves too fast

I found this code in this newsgroup and used it, but the lines drawn
are composed of point too separated when the mouse moves at medium or
fast speed. How can I fix it?

Thanks in advance !!!

Dim bTracking As Boolean
Dim blackPen As Pen
Dim g As Graphics

Private Sub frmFirma_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
blackPen = New Pen(Color.Black, 2)
blackPen.LineJoin = Drawing2D.LineJoin.Round
g = PictureBox1.CreateGraphics()
End Sub

Private Sub AddPoint(ByVal e As
System.Windows.Forms.MouseEventArgs)
g.DrawLine(blackPen, e.X, e.Y, e.X + 1, e.Y + 1)
End Sub

Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e
As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
bTracking = True
AddPoint(e)
End Sub

Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e
As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
If bTracking Then
AddPoint(e)
End If
End Sub

Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
If bTracking Then
AddPoint(e)
bTracking = False
End If
End Sub

Protected Overrides Sub Finalize()
g.Dispose()
MyBase.Finalize()
End Sub
Nov 20 '05 #1
5 2351
"Manuel Daponte" <md******@prtc.net> schrieb
I found this code in this newsgroup and used it, but the lines
drawn are composed of point too separated when the mouse moves at
medium or fast speed. How can I fix it?


Draw lines instead of points.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2
I found this code in this newsgroup and used it, but the lines
drawn are composed of point too separated when the mouse moves at
medium or fast speed. How can I fix it?
Draw lines instead of points.


Actually, I'm drawing small lines (2 points)...

The thing is that this will be used in a picture box, in an tabletPC app, to pick a signature. Do you have a better chunk of code
for that?

Thanks in advance for you help !!!

--
Manuel Daponte
Nov 20 '05 #3
* "Manuel Daponte" <md******@prtc.net> scripsit:
I found this code in this newsgroup and used it, but the lines
drawn are composed of point too separated when the mouse moves at
medium or fast speed. How can I fix it?

Draw lines instead of points.


Actually, I'm drawing small lines (2 points)...

The thing is that this will be used in a picture box, in an tabletPC app, to pick a signature. Do you have a better chunk of code
for that?


I think that's already a good solution. There may be better solutions
using interpolation to make everything look more smooth, but I think
that's too much effort...

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #4

"Manuel Daponte" <md******@prtc.net> wrote
Draw lines instead of points.
Actually, I'm drawing small lines (2 points)...

The thing is that this will be used in a picture box, in an tabletPC app, to pick a signature. Do you have a better chunk of

code for that?

Thanks in advance for you help !!!

Here is a quick example of drawing on the form. (Drawing on the form
offers no persistance) Paste the code below in a new project, AFTER
the designer code section:

HTH
LFS
Private grx As Graphics
Private mouse As Point
Private ink As Pen = New Pen(Color.MidnightBlue, 3)

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
grx = Me.CreateGraphics
grx.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
End Sub

Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
Dim pos As Point = New Point(e.X, e.Y)
If e.Button = MouseButtons.Left Then
grx.DrawLine(ink, mouse, pos)
mouse = pos
End If
End Sub

Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
mouse = New Point(e.X, e.Y)
End Sub

Nov 20 '05 #5
It's perfect !!! Thanks !!!

--
Manuel A. Daponte Santiago
--------------------------
DBA Municipio de Guaynabo

"Larry Serflaten" <se*******@usinternet.com> wrote in message news:Oq****************@tk2msftngp13.phx.gbl...

"Manuel Daponte" <md******@prtc.net> wrote
Draw lines instead of points.
Actually, I'm drawing small lines (2 points)...

The thing is that this will be used in a picture box, in an tabletPC app, to pick a signature. Do you have a better chunk of

code for that?

Thanks in advance for you help !!!

Here is a quick example of drawing on the form. (Drawing on the form
offers no persistance) Paste the code below in a new project, AFTER
the designer code section:

HTH
LFS
Private grx As Graphics
Private mouse As Point
Private ink As Pen = New Pen(Color.MidnightBlue, 3)

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
grx = Me.CreateGraphics
grx.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
End Sub

Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
Dim pos As Point = New Point(e.X, e.Y)
If e.Button = MouseButtons.Left Then
grx.DrawLine(ink, mouse, pos)
mouse = pos
End If
End Sub

Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
mouse = New Point(e.X, e.Y)
End Sub


Nov 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Anand Ganesh | last post by:
Hi All, In my application I am allowing the user to draw a line. But when the user clicks the start point and starts moving the mouse there is a series of line generated. When the mouse is up...
6
by: Rene | last post by:
I tried searching the newsgroups to see how do you draw a dotted line but I was unable to find an answer, drawing a straight line is very easy but not a dotted one. So the question is, how do I...
1
by: YouPoP | last post by:
I am doing an app (C# 2.0) where you can draw in a panel with your mouse in "real time". I actually have 2 problems; 1- it does not really is "real time", if your mouse move fast or very fast the...
5
by: Macias | last post by:
Hi, Please help me, how I can make a line drawing on PictureBox similar to MS paint. I thinking about this: click and hold button, move mouse and relase button. I'm trying useing this...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.