Draw a line

  • Thread starter Thread starter Mathieu Chavoutier
  • Start date Start date
M

Mathieu Chavoutier

Hi.

I would like to do something like paint.
I try to draw a line. I want, like paint, that when I clickdown, it begins
to draw the line, and then, when I move the mouse, the line follow the
cursor.
I have tried many things, and I have mysterious things appening.

Here, I can't remove the lines I have drawed :
http://img26.exs.cx/img26/4302/GRRRRRRRRRRRR.png

How could I do ?

Thanks in advance
 
Hi Mathieu,

Well, this post would probably get better response from the Drawing group, but a couple of ways to clear the line are:

1) Invalidate the portion of the window containing the last line and then draw the new line,

2) Redraw the old line using the background color (white) before drawing the new line.
 
Morten Wennevik said:
Hi Mathieu,

Well, this post would probably get better response from the Drawing group,
but a couple of ways to clear the line are:

Could you tell me wich one, please ?
I'm interest in it :D
1) Invalidate the portion of the window containing the last line and then
draw the new line,

Unfortunately, it doesn't works.
2) Redraw the old line using the background color (white) before drawing
the new line.

I can have other things displayed under the line. So, drawing in white is
not possible.

I will redo a post in the appropriate news group, when I will have it.

Thanks.
 
but a couple of ways to clear the line are:

Could you tell me wich one, please ?
I'm interest in it :D

microsoft.public.dotnet.framework.drawing

You might also want to read Bob Powel's GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm
draw the new line,

Unfortunately, it doesn't works.

This should work if you draw on a control accepting Invalidate(region).
The idea is that you repaint the graphics that should be there while outdated lines will not be redrawn. The region part is for preventing the entire area from repainting which is usually unecessary.
 
Morten Wennevik said:
microsoft.public.dotnet.framework.drawing

You might also want to read Bob Powel's GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Thnaks for both.
This should work if you draw on a control accepting Invalidate(region).

I can invalidate, It works for other bitmap that I print.
But, for the line, I obtain either the screenshot or nothing.
The idea is that you repaint the graphics that should be there while
outdated lines will not be redrawn. The region part is for preventing the
entire area from repainting which is usually unecessary.

In fact, I have tried to do so. But, it does not works.
When I draw what was before the line, I see a white square (the invalidate),
but suddenly, it is removed, and I see the lines that I wanted to remove.

I will post on the other newsGroup, and read your link, thanks you very
much.
 
Back
Top