🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #791

Re: How can I take a screen shot?

#791
From: Jonathan Benedicto
Date: Fri, 11 Jan 2008 22:39
37 lines
1926 bytes
Bashar Termanini wrote:
> I use this code to capture the screen
> HWND hWnd = GetDesktopWindow();
> HWND hDC  = GetWindowDC( hWnd );

First, a device context handle isn't a HWND. You should use HDC.

> Image1->Width   = Screen->Width;
> Image1->Height   = Screen->Height;
> BitBlt( Image1->Canvas->Handle, 0, 0, Screen->Width, Screen->Height, hDC, 
> 0,
> 0, SRCCOPY );
> It works first time. But when the Desktop change it still give me the 
> first
> screen shot.

Because the TImage component isn't redrawing the updated image to the 
screen.

Try this code instead:

HDC dc = GetDC( NULL );
if( dc )
{
    Image1->Width = Screen->Width;
    Image1->Height = Screen->Height;

    BitBlt( Image1->Canvas->Handle, 0, 0, Screen->Width, Screen->Height, dc, 
0, 0, SRCCOPY );
    ReleaseDC( NULL, dc );

    Image1->Repaint();
}

HTH

Jon 
Technical Details
Message-ID: <4787f042$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <477eabc5@newsgroups.borland.com> <MPG.21e8f11d54bf16ac9899c6@newsgroups.borland.com> <4787e357@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,9a955b0dfec9583
X-Google-Attributes: gid10cc67,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Jonathan Benedicto" <invalid@nobody.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <477eabc5@newsgroups.borland.com> <MPG.21e8f11d54bf16ac9899c6@newsgroups.borland.com> <4787e357@newsgroups.borland.com>
Subject: Re: How can I take a screen shot?
Date: Fri, 11 Jan 2008 17:39:59 -0500
Lines: 39
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198
X-RFC2646: Format=Flowed; Response
NNTP-Posting-Host: 99.238.204.170
Message-ID: <4787f042$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1200091202 99.238.204.170 (11 Jan 2008 14:40:02 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail