Article View: borland.public.cppbuilder.nativeapi
Article #14192Re: Screen Capture of TForm
From: CC
Date: Wed, 03 Sep 2003 22:32
Date: Wed, 03 Sep 2003 22:32
54 lines
2843 bytes
2843 bytes
Actually - I have solved part of my previous problem.
The problem is:
ScreenWidth = GetDeviceCaps(hScreenDC, HORZRES);
ScreenHeight = GetDeviceCaps(hScreenDC, VERTRES);
The HORZRES, etc gets dimensions of physical screen , not the width of my
device context.
If i could figure out how to get dimension of the window itself (not the
screen) my problem would be
fixed.
Thanks,Curt
"CC" <Xcurtc@tmscorp.com> wrote in message
news:3f56694f$1@newsgroups.borland.com...
> 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:
<3f566be9@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-08!supernews.com!priapus.visi.com!news-out.visi.com!petbe.visi.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!colt.net!diablo.theplanet.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<3f56694f$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,a5edb576acfde612,start 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 References: <3f56694f$1@newsgroups.borland.com> Subject: Re: Screen Capture of TForm Date: Wed, 3 Sep 2003 17:32:47 -0500 Lines: 56 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: <3f566be9@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1062628329 208.254.250.201 (3 Sep 2003 15:32:09 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-08!supernews.com!priapus.visi.com!news-out.visi.com!petbe.visi.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!colt.net!diablo.theplanet.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail