home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 October / Chip_2001-10_cd1.bin / zkuste / delphi / kolekce / d56 / TDSOFT.ZIP / TDScreenStamp.pas < prev    next >
Pascal/Delphi Source File  |  2001-04-06  |  2KB  |  67 lines

  1. {*******************************************************}
  2. {                                                       }
  3. {       TDSoft Visual Component Library                 }
  4. {                                                       }
  5. {       Copyright (c) 2001 Daniele Teti                 }
  6. {                                                       }
  7. {-------------------------------------------------------}
  8. {       For suggest, request, bug or only for sport:    }
  9. {       Daniele_Teti@hotmail.com                        }
  10. {-------------------------------------------------------}
  11. {                                                       }
  12. {                                                       }
  13. {*******************************************************}
  14.  
  15. unit TDScreenStamp;
  16.  
  17. interface
  18.  
  19. uses
  20.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
  21.  
  22. {$R *.DCR}
  23.  
  24. type
  25.   TTDScreenStamp = class(TComponent)
  26.   private
  27.     { Private declarations }
  28.   protected
  29.     { Protected declarations }
  30.   public
  31.     { Public declarations }
  32.     function CaptureScreen:TBitmap;
  33.   published
  34.     { Published declarations }
  35.   end;
  36.  
  37. procedure Register;
  38.  
  39. implementation
  40.  
  41. procedure Register;
  42. begin
  43.   RegisterComponents('TDSoft', [TTDScreenStamp]);
  44. end;
  45.  
  46. { TTDScreenStamp }
  47.  
  48. function TTDScreenStamp.CaptureScreen: TBitmap;
  49. var
  50.   DC : HDC;
  51.   ABitmap:TBitmap;
  52. begin
  53.   DC := GetDC (GetDesktopWindow);
  54.   ABitmap:=TBitmap.Create;
  55.   try
  56.     ABitmap.Width  := GetDeviceCaps (DC, HORZRES);
  57.     ABitmap.Height := GetDeviceCaps (DC, VERTRES);
  58.     BitBlt(ABitmap.Canvas.Handle, 0, 0, ABitmap.Width,
  59.            ABitmap.Height,DC, 0, 0, SRCCOPY);
  60.   finally
  61.     ReleaseDC (GetDesktopWindow, DC);
  62.   end;
  63. Result:=ABitmap;
  64. end;
  65.  
  66. end.
  67.