Article View: borland.public.cppbuilder.nativeapi
Article #14856Re: GetDC Function
From: vERUs
Date: Mon, 28 Jul 2003 21:19
Date: Mon, 28 Jul 2003 21:19
41 lines
2241 bytes
2241 bytes
Here's a old post on how to do this:
void __fastcall CaptureScreen(Graphics::TBitmap *Bitmap)
{
HDC HScreenDC = GetDC(0);
Bitmap->Handle = CreateCompatibleBitmap(HScreenDC,
Screen->Width,
Screen->Height);
int result = GetDeviceCaps(HScreenDC, RASTERCAPS);
if (result & RC_PALETTE)
{
int palette_size = GetDeviceCaps(HScreenDC, SIZEPALETTE);
if (palette_size == 256)
{
int size = sizeof(LOGPALETTE) + 256 * sizeof(PALETTEENTRY);
LPLOGPALETTE lplogpal =
(LPLOGPALETTE) new unsigned char[size];
lplogpal->palVersion = 0x300;
lplogpal->palNumEntries = 256;
GetSystemPaletteEntries(HScreenDC, 0, 256,
lplogpal->palPalEntry);
Bitmap->Palette = CreatePalette(lplogpal);
delete [] lplogpal;
}
}
BitBlt(Bitmap->Canvas->Handle, 0, 0, Bitmap->Width,
Bitmap->Height, HScreenDC, 0, 0,
SRCCOPY);
ReleaseDC(0, HScreenDC);
}
void __fastcall TForm1::CaptureButtonClick(TObject *Sender)
{
CaptureScreen(Image1->Picture->Bitmap);
}
/ vERUs
Technical Details
Message-ID:
<3f25937b@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!small1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<3f2461b8@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,da7ae4b16663c3b1 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-07-28 14:40:31 PST From: "vERUs" <verus@privat.utfors.se> Newsgroups: borland.public.cppbuilder.nativeapi References: <3f2461b8@newsgroups.borland.com> Subject: Re: GetDC Function Date: Mon, 28 Jul 2003 23:19:55 +0200 Lines: 43 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4920.2300 X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4920.2300 NNTP-Posting-Host: 212.105.16.12 Message-ID: <3f25937b@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1059427195 212.105.16.12 (28 Jul 2003 14:19:55 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!small1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail