Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invalidate into own bitmap

Tags:

I wish to off-screen render a Control to some bitmap so that I have quick access to it.

Unfortunately Control.DrawToBitmap seems to draw the entire control on which it is called including all it's child controls. Internally it issues a WM_PRINT message with self-provided DC to a bitmap. This temporary bitmap is then blitted to the user-provided Bitmap. Unacceptable for me, I'd rather have this bitmap updated as needed so my performance hit when the bitmap is needed is minimized.

In the ideal scenario I'd want the form to behave as if it were visible on the screen (but it cannot be). That would mean that if, say, some Control has its Text property changed, the form would be partially invalidated. Catching the relevant messages/events would then allow me to either specify my own DC for the form to be drawn on, or to simply BitBlt the forms DC to my own.

Some directions I have looked in:

  • The PaintEventArgs parameter in OnPaint seems to hold a member savedGraphicsState, perhaps it could be used to figure out what doesn't require invalidating
  • Having the form visible but outside the screen area. Controls then don't get painted, though.
  • Manually calling RedrawWindow() on the window, same story