Board index » cppbuilder » Copying the window contents to bitmap

Copying the window contents to bitmap

Hi.

How can i copy a whole windows contents (it's "appearance")? I cant use
BitBlt or Canvas->CopyRect because these functions will copy any window on
top of the source window, and sometimes omit the areas which are out of
screen. Is there a way to copy the screen "as is" without the disturbances
of other overllapping windows or clipped areas?

Thanks

 

Re:Copying the window contents to bitmap


Quote
>>Is there a way to copy the screen "as is" without the disturbances

of other overllapping windows or clipped areas?

Not as far as I know. The window must be a top-level window and completely
visible.

--
Kent (TeamB and TurboPower Software)
C++Builder Developer's Journal
http://www.reisdorph.com

Re:Copying the window contents to bitmap


Thanks.

Can you think of a way to "clear" the area and prepare the window for a
one-time "copy-to-bitmap" ? I mean, no windows can disturb (meaning the window
has to be set to foreground (does SetForegroundWindow() overpower dialogs ?),
and the window must be in the clipping region - (is there a way to check this
?).
Thank you very much for your help

Re:Copying the window contents to bitmap


hi,

try
void __fastcall PaintTo(HDC DC, int X, int Y);

Graphics::TBitmap* Form1Cap = new Graphics::TBitmap();
Form1Cap->Width = Form1->Width;
Form1Cap->Height = Form1->Height;
Form1->PaintTo(Form1Cap->Canvas->Handle, 0, 0);
Form1Cap->SaveToFile("capture.bmp");
delete Form1Cap;

not tested but could work ;-)

an other way is to send a WM_PAINT Message to Form1->Handle

::SendMessage(Form1->Handle, WM_PAINT, (WPARAM)Form1Cap->Canvas->Handle, 0);
but in this case you may get only the Form an not the controls in it.

good luck
bye
matthias

Quote
On Thu, 27 Apr 2000 21:42:11 +0200, Pavius <p...@hotmail.com> wrote:
>Thanks.

>Can you think of a way to "clear" the area and prepare the window for a
>one-time "copy-to-bitmap" ? I mean, no windows can disturb (meaning the window
>has to be set to foreground (does SetForegroundWindow() overpower dialogs ?),
>and the window must be in the clipping region - (is there a way to check this
>?).
>Thank you very much for your help

Other Threads