Article View: borland.public.cppbuilder.nativeapi
Article #14937Re: screen capture
From: Giuliano
Date: Mon, 28 Jul 2003 08:22
Date: Mon, 28 Jul 2003 08:22
37 lines
1932 bytes
1932 bytes
On Sun, 27 Jul 2003 04:00:34 -0800, "micheal davis"
<micheal_davis@hotmail.com> wrote:
>hi all,
>
>I am trying to get a screen capture of the current desktop and then save it
>to a bitmap file from my application, after searching msdn, I found the
>keybd_event() function, although it takes a screen shot of my current
>program windows, can anyone tell me please how to make it take a shot for
>all of the desktop...
>
>I am using the code
>
>keybd_event(VK_SNAPSHOT, 0, 0, 0);
>
>
Despite this is the nativeapi group, you could try
this VCL solution:
#include <memory>
void capture( AnsiString FileName )
{
const TRect Rect(
0, 0, Screen->DesktopRect.Width(), Screen->DesktopRect.Height()
);
std::auto_ptr<Graphics::TBitmap> Bmp( new Graphics::TBitmap );
std::auto_ptr<TCanvas> Cnvs( new TCanvas );
Bmp->Width = Rect.Width();
Bmp->Height = Rect.Height();
Cnvs->Handle = GetDC( 0 );
Bmp->Canvas->CopyRect( Rect, Cnvs.get(), Rect );
Bmp->SaveToFile( FileName );
}
Giuliano
Technical Details
Message-ID:
<kan9ivkakqhe0o147vfbco3gkr6dir5968@4ax.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mailReferences:
<3f23bee4@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,3421856959936173 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-07-28 01:38:32 PST From: Giuliano <gcardinali@remove.adhoc.net> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: screen capture Date: Mon, 28 Jul 2003 10:22:57 +0200 Message-ID: <kan9ivkakqhe0o147vfbco3gkr6dir5968@4ax.com> References: <3f23bee4@newsgroups.borland.com> X-Newsreader: Forte Agent 1.91/32.564 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 81.72.236.130 X-Trace: newsgroups.borland.com 1059380576 81.72.236.130 (28 Jul 2003 01:22:56 -0700) Lines: 37 Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail