(7) Crawl the form or control picture form
Create a new Form2 and save it as Capture2.pas. Set the four properties of the attribute BorderIcons to false.
BorderStyle is set to bsNone, FormStyle is set to fsStayOnTop.
Two common variables: fRect:TRect,fBmp:TBitmap;
unit Capture2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm2 = class(TForm)
PRocedure FormCreate(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormPaint(Sender: TObject);
procedure FormMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
Private
{ Private declarations }
public
fRect:TRect;
fBmp:TBitmap;
end;
var
Form2: TForm2;
Implementation
{$R *.dfm}
//Create a new custom cursor CURSOR_1 and place it in Capture2.res resource
//In the file, there is a white rectangular border of 32*32 to indicate the range of the capture.
procedure TForm2.FormCreate(Sender: TObject);
var aDC:HDC;
const crHand = -18;
Begin
Screen.Cursors[crHand]:=LoadCursor(hInstance,'CURSOR_1');
Cursor:=crHand;
fBmp:= TBitmap.Create ;
fBmp.Width := Screen.Width ;
fBmp.Height:= Screen.Height ;
aDC := GetDC(0);
BitBlt(fBmp.Canvas.Handle,0,0,Screen.Width,Screen.Height,aDC,0,0,srcCopy);
ReleaseDC(0,aDC);
SetBounds(0,0,Screen.Width,Screen.Height);
end;
procedure TForm2.FormActivate(Sender: TObject);
const crHand=-18;
Begin
Screen.Cursors[crHand]:=LoadCursor(hInstance,pChar('CURSOR_1'));
Cursor:=crHand;
end;
procedure TForm2.FormDestroy(Sender: TObject);
Begin
fBmp.Free;
Screen.Cursor := crDefault;
end;
procedure TForm2.FormPaint(Sender: TObject);
Begin
Canvas.Draw(0,0,fBmp);
end;
procedure TForm2.FormMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
Begin
ModalResult:=mrOK;
end;
end.