Example Delphi
Delphi Examples Collection
Today, Delphi is one of the popular desktop programming tool. There are thousand even million programmer in this world using delphi as their favorit tool. This site try to collect the examples, tips and tricks of Delphi programming. We collect, test them and redistribute the collection of delphi programming for you.
Capture Desktop Screenshot to Clipboard
Author: admin | Category: Graphic, Windows API
//This is how we can capture desktop screen to bitmap //then put into clipboard //Here we use Button1 (TButton) to run CaptureDesktop() procedure //We can Paste the result into image painter like Paint, etc. unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls; type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation USES Clipbrd; {$R *.dfm} procedure CaptureDesktop(); var DCDesktop: HDC; //HDC of Desktop BmpDesktop:TBitmap; begin {Creating a Bitmap} BmpDesktop := TBitmap.Create; try BmpDesktop.Height := Screen.Height; BmpDesktop.Width := Screen.Width; {Get a desktop DC Handle-handle of a display device context} DCDesktop := GetWindowDC(GetDesktopWindow); {Copy to any canvas, here canvas of an image} BitBlt(BmpDesktop.Canvas.Handle,0,0,Screen.Width,Screen.Height,DCDesktop,0, 0,SRCCOPY); {Copy bitmap into clipboard} Clipboard.Assign(BmpDesktop); finally BmpDesktop.Free end end; procedure TForm1.Button1Click(Sender: TObject); begin CaptureDesktop; end; end.
Post Meta
-
Graphic, Windows API -
Comments Feed -