Article View: borland.public.cppbuilder.nativeapi
Article #2979Re: screen to bitmap API
From: JF Jolin
Date: Thu, 26 Oct 2006 16:55
Date: Thu, 26 Oct 2006 16:55
59 lines
2451 bytes
2451 bytes
> Remy Lebeau (TeamB) <no.spam@no.spam.com> wrote:
> news:4540e4bb$1@newsgroups.borland.com...
>
>> Simply retreive the HDC for the window and then BitBlt() it into your
>> bitmap's HDC.
>
Example "Capturing an image" taken from help file.
/*
* Create a normal DC and a memory DC for the entire screen. The
* normal DC provides a "snapshot" of the screen contents. The
* memory DC keeps a copy of this "snapshot" in the associated
* bitmap.
*/
hdcScreen = CreateDC("DISPLAY", NULL, NULL, NULL);
hdcCompatible = CreateCompatibleDC(hdcScreen);
/* Create a compatible bitmap for hdcScreen. */
hbmScreen = CreateCompatibleBitmap(hdcScreen,
GetDeviceCaps(hdcScreen, HORZRES),
GetDeviceCaps(hdcScreen, VERTRES));
if (hbmScreen == 0)
errhandler("hbmScreen", hwnd);
/* Select the bitmaps into the compatible DC. */
if (!SelectObject(hdcCompatible, hbmScreen))
errhandler("Compatible Bitmap Selection", hwnd);
/* Hide the application window. */
ShowWindow(hwnd, SW_HIDE);
/*
* Copy color data for the entire display into a
* bitmap that is selected into a compatible DC.
*/
if (!BitBlt(hdcCompatible,
0,0,
bmp.bmWidth, bmp.bmHeight,
hdcScreen,
0,0,
SRCCOPY))
errhandler("Screen to Compat Blt Failed", hwnd);
/* Redraw the application window. */
ShowWindow(hwnd, SW_SHOW);
__
JF Jolin
Technical Details
Message-ID:
<op.th1fyxaajr09w3@localhost>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news.glorb.com!solnet.ch!solnet.ch!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<4540c2b4@newsgroups.borland.com> <4540e4bb$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,8704e1b73d3cb1f7 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit Date: Thu, 26 Oct 2006 12:55:35 -0400 Subject: Re: screen to bitmap API Newsgroups: borland.public.cppbuilder.nativeapi References: <4540c2b4@newsgroups.borland.com> <4540e4bb$1@newsgroups.borland.com> From: "JF Jolin" <jfj@nospam.com> Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID: <op.th1fyxaajr09w3@localhost> User-Agent: Opera M2/8.54 (Win32, build 7730) NNTP-Posting-Host: 66.36.133.10 X-Trace: newsgroups.borland.com 1161881724 66.36.133.10 (26 Oct 2006 09:55:24 -0700) Lines: 59 Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news.glorb.com!solnet.ch!solnet.ch!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail