国产探花免费观看_亚洲丰满少妇自慰呻吟_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)

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

新聞熱點

疑難解答

圖片精選

網友關注

主站蜘蛛池模板: 阜阳市| 石家庄市| 通化县| 涪陵区| 兴化市| 乐平市| 界首市| 凌源市| 共和县| 曲麻莱县| 岗巴县| 沙雅县| 郴州市| 滦平县| 昌乐县| 商丘市| 龙游县| 肃南| 自治县| 庆阳市| 锡林郭勒盟| 抚松县| 石门县| 中卫市| 闸北区| 阳春市| 芷江| 铁岭市| 许昌市| 海宁市| 扶沟县| 阜南县| 安达市| 乐平市| 隆林| 鹿邑县| 渝中区| 绿春县| 平遥县| 屏南县| 中山市|