Re: PaintBox image trouble



UN wrote:
There is an image painted into a PaintBox. If some other program form covers it, the image becomes distorted. Could it be protected in some way (other than Stay-On-Top)? The OnPaint event 'PaintBoxPaint' of the component PaintBox draws the image.

TPaintBox paints only what you've told it to paint, and only when you tell it to. If the image is distorted, it's because you've distorted it.


If the window was partially covered and then revealed, Windows will only update the portion of the window that was covered. It won't allow changes to the part that wasn't covered. This is called the clipping rectangle. It should be available in the Canvas.ClipRect property. You can use that property to determine how much of the image you need to recalculate during your painting routine.

If the calculations are lengthy, but they don't change often, then you can paint the image once to a TBitmap, and then in your OnPaint handler, just use Canvas.Draw(Bitmap, 0, 0) to copy the pre-drawn bitmap onto the screen.

--
Rob
.



Relevant Pages

  • Re: PaintBox image trouble
    ... Could it be protected in some way (other than Stay-On-Top)? ... The OnPaint event 'PaintBoxPaint' of the component PaintBox draws the image. ... Real Programmers Do things like this. ...
    (alt.comp.lang.borland-delphi)
  • Re: Updating the screen
    ... Thanks Tom, but that's not really what I have - I am trying to get a dialog ... window to update the screen when resized. ... If I step into the code, the OnPaint event is firing and my code ... is running and getting the correct new window sizes, ...
    (microsoft.public.vc.mfc)
  • Re: Updating the screen
    ... Thanks Tom, but that's not really what I have - I am trying to get a ... dialog window to update the screen when resized. ... I capture the OnPaint ... If I step into the code, the OnPaint event is firing and ...
    (microsoft.public.vc.mfc)