mistik1
10-02-2006, 11:23 PM
I have a project that deals with drawing lines. Currently when I push the draw button the new lines are just drawn over the old lines. I would like to erase the old lines so nothing shows but the new lines. I am having a really tough time figuring out how to do this.
In the form_load event I create a bitmap called picImg that I get like this
g1 = Graphics.fromhwnd(picturebox1.handle)
picImg = new bitmap(picturebox1.clientrectangle.width, picturebox1.clientrectangle.height,g1)
With the button I draw a couple lines. Something like this
g2 = graphics.fromimage(picImg)
p1 = new pen(color.black,1)
g2.drawline(.....)
picturebox1.invalidate(false) 'not sure what this does
And in the paint event for picturebox1 I have
e.Graphics.drawimage(picImg,0,0)
I like how the lines stay drawn after a minimize so I want to keep that functionality. But I also want to erase the current lines when I click the button so I can draw the new lines without seeing the old as well.
In the form_load event I create a bitmap called picImg that I get like this
g1 = Graphics.fromhwnd(picturebox1.handle)
picImg = new bitmap(picturebox1.clientrectangle.width, picturebox1.clientrectangle.height,g1)
With the button I draw a couple lines. Something like this
g2 = graphics.fromimage(picImg)
p1 = new pen(color.black,1)
g2.drawline(.....)
picturebox1.invalidate(false) 'not sure what this does
And in the paint event for picturebox1 I have
e.Graphics.drawimage(picImg,0,0)
I like how the lines stay drawn after a minimize so I want to keep that functionality. But I also want to erase the current lines when I click the button so I can draw the new lines without seeing the old as well.