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

首頁 > 編程 > Delphi > 正文

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

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

(六)TMainForm的 (抓圖)Action 事件
1)全屏抓圖
[Capture Desktop]  Action 事件
PRocedure TMainForm.cptDesktopExecute(Sender: TObject);
begin
  inc(CaptureNum,1);
  application.Minimize ;  //窗體最小化
  Delay(500);             //最小化后延時,為了全屏抓圖不把自身抓進圖中
  FileName:='Capture'+IntToStr(CaptureNum)+'.bmp';
  FileName:=DefaultDirectory+FileName;
  CreateMDIChild(FileName,true);
  StatusBar.SimpleText := FileName;
  with ActiveMDIChild as TMDIChild do begin
    Image1.Picture.Bitmap := CaptureScreen;         //抓圖
    HorzScrollBar.Range := Image1.Picture.Width;
    VertScrollBar.Range := Image1.Picture.Height;
  end;
  Child.Image1.Hint := 'Height:'+intToStr(child.Image1.Picture.Height)+'pixels'
                     + ' Width:'+intToStr(child.Image1.Picture.Width)+'pixels';
  application.Restore ;
end;

2)區域抓圖
   抓取區域圖片,即要用到一個新的Form1,參見《Delphi圖象截取編程示例(6)》  .
   在Main單元implementation的uses中添加Capture1。
   在Main單元添加私有過程CaptureArea :

procedure TMainForm.CaptureArea;
begin
  with TForm1.Create(Application) do
  try
    if ShowModal=mrOK then
    with fRect do begin
      if (Right>Left)and(Bottom>Top) then begin
        Delay(400);
        ABitmap:=TBitmap.Create;
        ABitmap.Assign(CaptureScreenRect(fRect));
        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;
        ABitmap.Free ;
      end else begin
        MessageDlg('選擇圖片區域錯誤,請重新選擇!',mtInformation,[mbOK],0);
        Child.Close ;
        Form1.Free ;
        exit;
      end;
    end;
  finally
    Free;
  end;
end;

[Capture Area]區域抓圖的Action 事件
procedure TMainForm.cptAreaExecute(Sender: TObject);
begin
  Inc(CaptureNum,1);
  Application.Minimize ;
  Delay(500);
  FileName:='Capture'+IntToStr(CaptureNum)+'.bmp';
  FileName:=DefaultDirectory+FileName;
  { Create MDI Child Window }
  CreateMDIChild(FileName,true);
  StatusBar.SimpleText := FileName;

  { Capture Area of screen }
  CaptureArea;
  Child.Image1.Hint := 'Height:'+intToStr(child.Image1.Picture.Height)+'pixels'
                     + ' Width:'+intToStr(child.Image1.Picture.Width)+'pixels';
  application.Restore ;
end;


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

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

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

新聞熱點

疑難解答

圖片精選

網友關注

主站蜘蛛池模板: 登封市| 玛曲县| 鄱阳县| 陇西县| 郁南县| 永新县| 鸡东县| 钟山县| 永泰县| 淳化县| 镇安县| 同仁县| 民和| 林芝县| 桂平市| 乐安县| 吉林市| 二连浩特市| 青河县| 新营市| 中江县| 清镇市| 嫩江县| 余庆县| 资阳市| 芮城县| 南川市| 仁布县| 南涧| 诏安县| 宜宾市| 抚松县| 清丰县| 保康县| 新津县| 万全县| 巫溪县| 勐海县| 都匀市| 泌阳县| 咸宁市|