Click here to Skip to main content
15,923,168 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a problem with my freehand drawing code:

this one is in Picturebox1_MouseMove

VB
Dim yourArray As Point() = {New Point(e.X - pw, e.Y - pw), New Point(e.X, e.Y)}
            Dim cle As System.Drawing.Graphics
            Dim myPath As New GraphicsPath
            Dim myColor As Color

            cle = myPhoto.CreateGraphics
            pw = tbThickness.Value

            If eventString = "L" Then
                myColor = btnColor.BackColor
                myPath.StartFigure()
                myPath.AddLines(yourArray)
                myPath.CloseFigure()
                cle.DrawPath(New Pen(myColor, pw), myPath)
            End If
            If eventString = Nothing Then
                myPath.Reset()
                cle.Flush()
            End If


The problem is, if I click on other buttons or maximize and minimize my window the drawing i made gets lost/erased.
Posted
Updated 19-Apr-12 22:30pm
v2
Comments
Dhanushka Madushan lk 20-Apr-12 5:48am    
check this
http://www.codeproject.com/Tips/318900/Drawing-on-picture-box-images

1 solution

You are probably doing it in the wrong place. When capturing details of the drawing you should build it as a list or array of lines, colours, thicknesses etc based on user input. However, you should only do the actual drawing in the Paint Event[^] of the control.
 
Share this answer
 
Comments
bnvelarde 20-Apr-12 5:50am    
how can i do it??
im just new in vb.net, and im just copying and editing what i saw on other post.
Richard MacCutchan 20-Apr-12 9:22am    
There is no point in using copy and paste if you do not understand what the code is doing. Spend some time looking at some of the articles here on CodeProject and also the Visual basic and .NET sections on MSDN, to learn about the language and .NET in general. You may also like to invest in a good book to help your learning process.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900