Delphi image intercept programming example (5)

xiaoxiao2021-03-06  114

3) Crawling the form or control image capture the form or control image, that is, to use a new Form2, see "Delphi Image Intercept programming example (7)" Add Capture2 in the USES of Main Unit IMplementation. [Capture Windows or Controls] form or control capture of Action event 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:' INTOSTR (child.image1.picture.height) 'Pixels' 'Width:' INTOSTR (Child.Image1.Picture.Wid TH) 'Pixels'; Abitmap.Free; End; Finally Free; Application.Restore; End;

4) Crawling the ICON image capture the icon image, that is, to use a new Form3, see "Delphi Image Intercept program example (8)" Add Capture3 in the USES for Main Unit IMPLEmentation. Add a private process in the main unit Captureicon: Procedure Tmainform.captureicon; // [twenty] Begin with TFORM3.CREATE (Application) Do trymodal = 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; Else Begin Messagedlg ('Border Select error, retry!', Mtinformation, [mbok], 0); child.close; form3.free EXIT; End; end; end; end; [Capture icon] icon gramphrograph Action event procedure (sender: TOBJECT); Begin Application.minimize; Delay (400); Inc (Capturenum, 1) FILENAME: = 'Capture' INTOSTR (Capturenum); FileName: = DefaultDirectory FileName; CreateMdichild (filename, true); status bar.simpletext: = file Name; 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;

转载请注明原文地址:https://www.9cbs.com/read-97521.html

New Post(0)