Drawing an Image over Another

M

Marcelo

Greetings!
I develop a multiple forms application on Microsoft Visual Studio C++
..NET 2003. In this application, I draw into a picture box using the
Invalidate() method a very "heavy" graphic (composed of lots of
elements).
What I need to do is, on each MouseMove event of the picture box, draw
a rectangle in front of this graphic in backgroud and erase the last
one. (draw a new, erase the old...)
The only way I found to do that is, each time the MouseMove event is
shot, call Invalidate() and redraw ALL the background image again, and
the new rectangle in front of it (the old one is so automatically
erased).
But this is impossible. The redrawing is very, very slow.
Wouldn't there be a way of leaving the backgroud image static and each
time I call Invalidate() just draw the rectangle in front of it?
I thank for any idea.
Marcelo Schio
 
R

Rodrigo Corral [MVP]

Don't invalidate all the picturebox. Invalidate only certain areas using
InvalidateRect instead of Invalidate.

You will need invalidate the old rectangle area and the new rectangle area.


--
Un saludo
Rodrigo Corral González [MVP]

FAQ de microsoft.public.es.vc++
http://rcorral.mvps.org
 
M

Marcelo

Muchas gracias. That's something like that I was looking for. But there
is still a problem: the InvalidateRect method is not a member of the
pictureBox class, like Invalidate(). How could I apply it in my
pictureBox, or to call my pictureBox_Paint event, for example?

Marcelo Roggia Schio
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top