Mega Code Archive

 
Categories / Delphi / Graphic
 

How Can I Capture the Screen to a Image

Title: How Can I Capture the Screen to a Image? Question: How Can I Capture the Screen to a Image? Answer: Capture a screen to a bitmap can be very simple. Just copy the bellow function and put in your program. function CaptureScreen:TBitmap; var DC : HDC; ABitmap:TBitmap; begin DC := GetDC (GetDesktopWindow); ABitmap:=TBitmap.Create; try ABitmap.Width := GetDeviceCaps (DC, HORZRES); ABitmap.Height := GetDeviceCaps (DC, VERTRES); BitBlt(ABitmap.Canvas.Handle, 0, 0, ABitmap.Width, ABitmap.Height,DC, 0, 0, SRCCOPY); finally ReleaseDC (GetDesktopWindow, DC); end; Result:=ABitmap; end;