Drawing on top of a static image

J

JMecc0

I am using VB.NET to draw a gauge; i.e. to repeatedly draw a needle
moving on top of a static image of the gauge background whenever the
value changes.

Each time the value changes, I can clear the current graphics to some
color, redraw the gauge background picture with Graphics.DrawImage and
then the needle on top of it with Graphics.DrawPolygon & FillPolygon,
but this seems very wateful as the background never changes.

If I set the control's BackImage as my image and then only draw the
needle though, the last few spots the needle was still show it there
so it looks like there are many needles. These all get cleaned up
periodically when OnPaint is called but only when called by the system
(when I trigger OnPaint no cleanup occurs).

What is the right way to do this?

Thanks,
Jo
 
S

SurturZ

Can you draw the needle on a separate transparent control that overlaps the
background image?
 
J

JMecc0

I guess I could do that too. Thanks for the tip.

I did resolve my issue though by adding Me.Refresh() such that the old
drawings could get whisked away.

Jo
 
S

SurturZ

I can't believe I haven't noticed it before but the PictureBox control in
VS2008 has a ".BackgroundImage" property as well as an ".Image" property.

In fact, it's a property of the Control class!!!

Maybe this will do what you need?
 

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