国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Delphi > 正文

Delphi圖象截取編程示例(5)

2019-11-18 18:12:08
字體:
來源:轉載
供稿:網友
 

3)抓取窗體或控件圖片
   抓取窗體或控件圖片,即要用到一個新的Form2,參見《Delphi圖象截取編程示例(7)》
   在Main單元implementation的uses中添加Capture2。
  
[Capture Windows or Controls]窗體或控件抓圖的Action 事件

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)抓取 ICON 圖片
抓取 ICON 圖片,即要用到一個新的Form3,參見《Delphi圖象截取編程示例(8)》
在Main單元implementation的uses中添加Capture3。
在Main單元添加私有過程CaptureICON :

procedure TMainForm.CaptureICON; // [二十]
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('邊框選擇錯誤,重試!',mtInformation,[mbOK],0);
          Child.Close ;
          Form3.Free ;
          exit;
        end;
      end;
  finally
    Free;
  end;
end;

[Capture ICON ] ICON 抓圖的Action 事件
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;


上一篇:Delphi圖象截取編程示例(7)

下一篇:Delphi圖象截取編程示例(4)

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
學習交流
熱門圖片

新聞熱點

疑難解答

圖片精選

網友關注

主站蜘蛛池模板: 义乌市| 葵青区| 吉水县| 化隆| 北安市| 卢龙县| 宜川县| 南木林县| 揭西县| 娄烦县| 安义县| 揭东县| 南康市| 尤溪县| 沈阳市| 于都县| 正定县| 琼结县| 深圳市| 东海县| 航空| 五莲县| 天长市| 马龙县| 汝阳县| 镇原县| 喀喇沁旗| 德昌县| 洛阳市| 东城区| 勐海县| 花莲市| 福海县| 广宗县| 武功县| 孟连| 福建省| 会昌县| 漯河市| 赤水市| 富顺县|