Scalabium Software

SMExport/SMImport suites
Knowledge for your independence'.
Home Delphi and C++Builder tips


#1: How can I create the screenshot and save into file?

In the next code I show how you can save in the file the current desktop image:

procedure TForm1.Button1Click(Sender: TObject);
var DCDesk: HDC; // hDC of Desktop
  bmp: TBitmap;
begin
  {Create a bitmap}
  bmp := TBitmap.Create;
   
  {Set a bitmap sizes}
  bmp.Height := Screen.Height;
  bmp.Width := Screen.Width;

  {Get a desktop DC handle - handle of a display device context}
  DCDesk := GetWindowDC(GetDesktopWindow);
  
  {Copy to any canvas, here canvas of an image}
  BitBlt(bmp.Canvas.Handle, 0, 0, Screen.Width, Screen.Height,
         DCDesk, 0, 0, SRCCOPY);

  {Save the bitmap}
  bmp.SaveToFile('ScreenShot.bmp');

  {Release desktop DC handle}
  ReleaseDC(GetDesktopWindow, DCDesk);

  {Release a bitmap}
  bmp.Free;
end;


Published: July 29, 1999

See also
 
Mail parser (ActiveX)
Excel Web-stream
Paradox Viewer
Metafile Convert
SMImport suite
DBExport tools
SMMsg suite
ABA Database Convert
Viewer for TNEF-files (winmail.dat)
Paradox ActiveX
 
 


Contact to webmaster

 

Borland Software Code Gear Scalabium Delphi tips

Copyright© 1998-2017, Scalabium Software. All rights reserved.
webmaster@scalabium.com

SMExport/SMImport suites