Simulate Autoredraw

D

Doug Marquardt

Hi All:

I want to simulate VB6 Autoredraw in VB.Net

I figure I would probably have to create a memory dc,
paint to that, and then create a bitmap based on the dc
and copy that image into a bitmap,
and then assign that to the image property of my control?

If so, then can someone push me in the right direction
to get started on this.

If not, then what would you suggest.

Thanks.

Doug.
 
G

Guest

Just create a bitmap that's persistent. You can then create a graphics
object from it and draw on the bitmap. In the paint event, you can use
bitblt to copy the bitmap to your form, picture box, or whatever. I have an
example if you like.
 
D

Doug Marquardt

Hi Dennis:

That was the first thing I looked at, but I couldn't
figure out how to draw to the bitmap (the only
method I saw was for setting pixels).

So how do you draw to the bitmap?

Doug.
 
D

Doug Marquardt

Hi Dennis:

I was able to figure out to create the graphics from the bitmap,
and was able to draw to it, etc.
Assigning the bitmap to the image property seems to work fine...
what advantages would there be to bitblt in the paint event?

Doug.
 
D

Doug Marquardt

Hi Dennis:

Pardon my ignorance here...
but I really don't see how bitblt in the paint event
could be quicker than assigning the bitmap
to the image -- the point being that once I assign
the image the control takes over all the painting, etc.???

Just curious...

Doug.
 
G

Guest

Use whatever you want. I personally use the bitblt and it's ligntning
quick. I would think that an image has to be rendered during each paint
event from a general format and copied to the picturebox or whatever. In VB6
and before, I think controls had the option of having their background
persistent in memory and didn't have to be redarwn to the picturebox, etc.
each time it was repainted. However, in VB.Net this changed so the image has
to be copied to the picturebox during each paint event.
 
D

Doug Marquardt

Hi Dennis:

Not sure what you mean by "copied to the picturebox during each paint
event"...
as I only have to assign the bitmap to the control image property and forget
about it. Are you saying that internally, vb.net has to copy/render any
image
each time the paint event is fired?

In any case, what I am doing now works just fine and I do not notice
any performance issues whatsoever.

Thanks for getting me started on the right path with this.

Doug.
 
G

Guest

Yes, that's what I mean. I could be wrong but from what I've read, each
paint event requires the image to be copied to the picturebox or at least
that part of it that needs to be redrawn. The picturebox is not displayed
from a persistent area of memory. Maybe someone on this newsgroup can
explain if I'm wrong or explain it better.
 

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