1
votes

I have a set of forms which are visualized as MDI tab children of a main form (through an Infragistics UltraTabbedMDIManager, but this API is not so important)

I use GetDC(), CreateCompatibleDC(), CreateCompatibleBitmap(), SelectObject(), BitBlt().. to blit the bitmap of the device contexts of these forms into some memory. This works, but only for the active MDI child form, the one that is visible to the user. If I do it for forms that are not active (any tabs that are not currently shown), I get a black screen in the memory area, or I even get a "copy" of the screen that's above it. If I do it for forms that are no longer visible, I also get a black screen.

What should I do to get a bitmap of these hidden forms? Do I have to resort to caching or is there some other trickery I can use? I cannot use Winforms DrawToBitmap() function, because the forms contain some low-level graphical things that cannot be retrieved with it. How can I use the winapi to retrieve a bitmap of these "hidden" forms' DC?

1
Your exact question has no simple answer. What exactly do you need drawn? The contents, full form, ...John Arlen
See my own answer below. I don't agree that the nature of the contents being shown has any relevance, by the way.buddhabrot

1 Answers

0
votes

I managed to do it using the PrintWindow API in user32.dll. It solves the MDI tabs problem, however it didn't solve the problem for hidden forms. I solved that problem by showign the forms briefly in some off-screen location. It seems the "ultimate" way is to use the (undocumented) dwm.dll, but this is not so advisable because interfaces differ between versions of Windows.