Go back to Richel Bilderbeek's homepage.
Go back to Richel Bilderbeek's C++ page.
Windows data type for a handle to a device context.
An HDC can be obtained by GetDC (among others) and must be released by ReleaseDC. Use Scoped_hdc for safe memory use.
HDC is declared in windef.h (at least in the library that shipped with C++ Builder 6.0).
MakeScreenshot retrieves the HDC of the desktop and copies it (using BitBlt) on a bitmap (or more specific: a Graphics::TBitmap).
MakeScreenshot uses the VCL data type Graphics::TBitmap supplied with C++ Builder 6.0.
#include <windows.h>
#include <Extctrls.hpp>
//From http://www.richelbilderbeek.nl/CppMakeScreenshot.htm
void MakeScreenshot(Graphics::TBitmap * const b)
{
assert(b);
assert(b->PixelFormat == pf32bit);
b->Width = Screen->Width;
b->Height = Screen->Height;
BitBlt(b->Canvas->Handle, 0, 0, b->Width, b->Height, desktop, 0, 0, SRCCOPY);
b->Modified = true;
ReleaseDC(0, desktop);
}
[0] ...
Go back to Richel Bilderbeek's C++ page.
Go back to Richel Bilderbeek's homepage.