Article View: borland.public.cppbuilder.nativeapi
Article #14193Screen Capture of TForm
From: CC
Date: Wed, 03 Sep 2003 22:21
Date: Wed, 03 Sep 2003 22:21
36 lines
2149 bytes
2149 bytes
Greetings all -
I'm trying to some screen snapshots. I managed to get a screen snapshot in
BITMAP form of the
desktop window. I would like to specify the window to get a snapshot of,
instead of taking the
snapshot of the entire desktop.
GetWindowDC(0) works for the desktop snapshot fine.
GetWindowDC(Handle); (where Handle is Form1->Handle); still gives me the
snapshot of the entire
desktop. I was expecting a bitmap of only the form.
What am I doing wrong?
Thanks,
CurtC
TForm::Button1Click()
{
//hScreenDC = GetWindowDC(0); // Get device context of desktop window
(works ok)
hScreenDC=GetWindowDC(Handle); // Try to get device context ONLY for
TFORM
// I get a device context, but the
snapshot is STILL of the
// desktop.
ScreenWidth = GetDeviceCaps(hScreenDC, HORZRES);
ScreenHeight = GetDeviceCaps(hScreenDC, VERTRES);
hmemDC = CreateCompatibleDC( hScreenDC );
hmemBM = CreateCompatibleBitmap(hScreenDC,ScreenWidth,ScreenHeight);
SelectObject(hmemDC, hmemBM);
BitBlt(hmemDC, 0, 0, ScreenWidth, ScreenHeight, hScreenDC, 0,
0,SRCCOPY);
SaveBitmapToFile(.........);
}
Technical Details
Message-ID:
<3f56694f$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!newsfeed.news2me.com!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,a5edb576acfde612 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-09-03 15:39:51 PST From: "CC" <Xcurtc@tmscorp.com> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Screen Capture of TForm Date: Wed, 3 Sep 2003 17:21:43 -0500 Lines: 38 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 208.254.250.201 Message-ID: <3f56694f$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1062627663 208.254.250.201 (3 Sep 2003 15:21:03 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!newsfeed.news2me.com!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail