Article View: borland.public.cppbuilder.nativeapi
Article #9327Re: screenshot
From: Remy Lebeau (TeamB)
Date: Thu, 15 Jul 2004 23:04
Date: Thu, 15 Jul 2004 23:04
45 lines
2320 bytes
2320 bytes
"Blake Young" <blakeyoung@mail.utexas.edu.NOSPAM> wrote in message
news:40f706e3$1@newsgroups.borland.com...
> I couldn't find an API command in the Platform SDK
> (probably wasn't looking hard enough) to perform
> a screen capture
That is because there is no such function. You have to capture the screen
manually, for example:
void __fastcall ScreenCapture(Graphics::TBitmap *Bitmap)
{
HDC hScreenDC = GetDC(0);
Bitmap->Handle = CreateCompatibleBitmap(hScreenDC, Screen->Width,
Screen->Height);
if( GetDeviceCaps(hScreenDC, RASTERCAPS) & RC_PALETTE )
{
int palette_size = GetDeviceCaps(hScreenDC, SIZEPALETTE);
if( palette_size > 0 )
{
const size_t size = sizeof(LOGPALETTE) +
(sizeof(PALETTEENTRY) * palette_size);
unsigned char* pBuffer = new unsigned char[size];
LPLOGPALETTE lplogpal =
reinterpret_cast<LPLOGPALETTE>(pBuffer);
lplogpal->palVersion = 0x300;
lplogpal->palNumEntries = palette_size;
GetSystemPaletteEntries(hScreenDC, 0, palette_size,
lplogpal->palPalEntry);
Bitmap->Palette = CreatePalette(lplogpal);
delete [] pBuffer;
}
}
BitBlt(Bitmap->Canvas->Handle, 0, 0, Bitmap->Width, Bitmap->Height,
hScreenDC, 0, 0, SRCCOPY);
ReleaseDC(0, hScreenDC);
}
Gambit
Technical Details
Message-ID:
<40f70d6f$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<40f706e3$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,8d58a97048b4776b X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <40f706e3$1@newsgroups.borland.com> Subject: Re: screenshot Date: Thu, 15 Jul 2004 16:04:36 -0700 Lines: 47 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 68.69.17.41 Message-ID: <40f70d6f$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1089932655 68.69.17.41 (15 Jul 2004 16:04:15 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail