Copy code
Tcanvas * dtcanvas = new tcanvas; dtcanvas-> handle = getdc (0);
Graphics :: Tbitmap * Bitmap = new graphics :: tbitmap; bitmap-> width = width; bitmap-> height = height;
int nColors = GetDeviceCaps (Canvas-> Handle, SIZEPALETTE); LOGPALETTE * logPal = (LOGPALETTE *) new Byte [sizeof (LOGPALETTE) (nColors-1) * sizeof (PALETTEENTRY)]; logPal-> palVersion = 0x300; logPal- > PALNUMENTRIES = (Word) Ncolors; getSystemPaletteentries (canvas-> handle, 0, ncolors, logpal-> palpalent); Bitmap-> Palette = CreatePalette (LogPal); delete [] logpal;
TRECT SRC = BoundSRect; TRECT DEST = Rect (0, 0, Width, Height); Bitmap-> Canvas-> CopyRect (DEST, DTCANVAS, SRC);
Bitmap-> SaveTofile ("Screen.BMP");
Delete Bitmap; Delete DTCANVAS;