3) Crawl the form or control picture
Grab a form or control image, that is, to use a new Form2, see "Delphi Image Intercept Programming Example (7)"
Add Capture2 in the uses of the Main unit implementation.
[Capture Windows or Controls] Action event for a form or control capture
PRocedure TMainForm.cptWindowsExecute(Sender: TObject);
var p:TPoint; Handles:HWnd;
Begin
Inc(CaptureNum,1);
application.Minimize ;
Delay(500);
FileName:='Capture'+IntTOStr(CaptureNum);
FileName:=DefaultDirectory+FileName;
with TForm2.Create(Application) do
try
if ShowModal=mrOK then
Begin
CreateMDIChild(FileName,true);
StatusBar.SimpleText := FileName;
Delay(500);
ABitmap:=TBitmap.Create;
GetCursorPos(P);
Handles:=WindowFromPoint(P);
ABitmap:=CaptureWindowImage(Handles);
Child.Image1.Picture.Bitmap:=ABitmap;
Child.ClientWidth := Child.Image1.Picture.Width ;
Child.ClientHeight:= Child.Image1.Picture.Height;
Child.HorzScrollBar.Range := Child.Image1.Picture.Width;
Child.VertScrollBar.Range := Child.Image1.Picture.Height;
Child.Image1.Hint := 'Height:'+intToStr(child.Image1.Picture.Height)+'pixels'
+ ' Width:'+intToStr(child.Image1.Picture.Width)+'pixels';
ABitmap.Free ;
end;
Finally
Free;
Application.Restore ;
end;
end;
4)Crawl ICON pictures
Grab an ICON picture, that is, to use a new Form3, see "Delphi Image Intercept Programming Example (8)"
Add Capture3 in the uses of the Main unit implementation.
Add private process CaptureICON in Main unit:
procedure TMainForm.CaptureICON; // [Twenty]
Begin
with TForm3.Create(Application) do
try
if ShowModal = mrOK then
with fRect do begin
if (Right>Left) and(Bottom>Top) then begin
Delay(300);
ABitmap:=TBitmap.Create;
ABitmap.Assign(CaptureScreenRect(fRect));
Child.Image1.Picture.Bitmap:=ABitmap;
Child.HorzScrollBar.Range:=Child.Image1.Picture.Width;
Child.VertScrollBar.Range:=Child.Image1.Picture.Height;
ABitmap.Free;
end else begin
MessageDlg('Border selection error, try again!',mtInformation,[mbOK],0);
Child.Close ;
Form3.Free;
exit;
end;
end;
Finally
Free;
end;
end;
[Capture ICON] Action event for ICON capture pictures
procedure TMainForm.cptIconExecute(Sender: TObject);
Begin
Application.Minimize ;
Delay(400);
Inc(CaptureNum,1);
FileName:='Capture'+intToStr(CaptureNum);
FileName:=DefaultDirectory+FileName;
CreateMDIChild(FileName,true);
StatusBar.SimpleText := FileName;
CaptureICON;
Child.ClientWidth := Child.Image1.Picture.Width ;
Child.ClientHeight:= Child.Image1.Picture.Height;
Child.HorzScrollBar.Range := Child.Image1.Picture.Width;
Child.VertScrollBar.Range := Child.Image1.Picture.Height;
Child.Image1.Hint := 'Height:'+intToStr(child.Image1.Picture.Height)+'pixels'
+ ' Width:'+intToStr(child.Image1.Picture.Width)+'pixels';
Application.Restore ;
end;