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
Can you draw the needle on a separate transparent control that overlaps the background image? -- David Streeter Synchrotech Software Sydney Australia "JMecc0@gmail.com" wrote: > 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 >
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
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? -- David Streeter Synchrotech Software Sydney Australia "JMecc0@gmail.com" wrote: > 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 >