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

首頁 > 編程 > Delphi > 正文

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

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

注意,本例在 Delphi7.0下調試通過
///////////////////////////////////////////////////////////

(一)建立項目
  new Items-->PRojects-->MDI application
 
(二)重新設計MDI子窗體--ChildWin,實現抓取的圖象在ChildWin中顯示。
    在ChildWin子窗體中去掉原有的Memo1控件,添加Image控件,Image1.Align=alClient。
    Image1.AutoSize=ture表示原尺寸顯示,Strech=false表示不按對象框顯示。

(三)主界面修改
  1)去掉 menu,toolbar,ActionList 中與 paste,new 相關的項
  2)添加 PrinterSetupDialog1,SaveDialog 控件到MainForm .
    添加菜單項file/打印,屬性name為filePrintItem;
    添加菜單項file/打印設置,屬性enabled=false,name為filePrintSet;
    添加菜單項edit/Draw ,它的屬性enabled=false ;
    添加菜單項edit/Preferences,設置它為包含字菜單(create Submenu);
    添加菜單項edit/Preferences/Configuration;
    添加菜單項edit/Preferences/ToolBar,它的checked=true,name=toolbarItem;
    添加菜單Image;
    添加菜單項Image/Capture Desktop;
    添加菜單項Image/Capture Area;
    添加菜單項Image/Capture Windows or Controls;
    添加菜單項Image/Capture Icon
   
    添加四個toolbar button 到 toolbar,對應Image菜單下的四個菜單項。
   
    添加四個Action到ActionList:cptDestop,cptArea,cptWindows,cptIcon;
    將Image菜單下的四個菜單項 的action屬性分別對應上面四個Action;
    將新增的四個toolbar button的action屬性分別對應上面四個Action。
   
  3)在Main單元中把implementation的uses CHILDWIN移到interface的uses中,
    添加ScrnCpt到interface的uses中;
    在TMainForm的public中添加定義:
        Child: TMDIChild;
        CaptureNum:integer;
        FileName:String;
        DefaultDirectory:string;
       
  4)在TMainForm添加私有函數:procedure Delay(msecs:integer)
procedure TMainForm.Delay(msecs:integer); //實現延時
var FirstTickCount:Longint;
begin
  FirstTickCount:=GetTickCount; //windows啟動到現在的時間(豪秒)
  repeat
    begin
      Application.ProcessMessages; //中斷程序讓windows能響應發生的事件
    end;
  until ((GetTickCount-FirstTickCount)>=Longint(msecs));
end;

  5)修改[TMainForm.CreateMDIChild]過程:
    去掉變量var Child: TMDIChild,添加參數newFile
procedure TMainForm.CreateMDIChild(const Name: string;newFile:boolean);
begin
  Child := TMDIChild.Create(Application); { create a new MDI child window }
  Child.Caption := Name;
  if (not newFile)and(Name<>'') then begin
    Child.Image1.Picture.Bitmap.LoadFromFile(Name);
    Child.HorzScrollBar.Range := Child.Image1.Picture.Width;
    Child.VertScrollBar.Range := Child.Image1.Picture.Height;
  end;
end;    


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

下一篇:Delphi中MIDAS如何控制前臺權限(MIDAS之六)

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

新聞熱點

疑難解答

圖片精選

網友關注

主站蜘蛛池模板: 潮安县| 错那县| 韶关市| 维西| 三都| 苏尼特左旗| 吉林市| 霍山县| 江永县| 张家港市| 东丰县| 永嘉县| 修水县| 临泉县| 武鸣县| 博兴县| 宜昌市| 喀喇沁旗| 峨山| 钟山县| 浮梁县| 祁连县| 辉县市| 英吉沙县| 石门县| 内丘县| 宿州市| 北宁市| 台山市| 新田县| 萍乡市| 宁武县| 慈溪市| 沙田区| 兴仁县| 临沭县| 额尔古纳市| 深水埗区| 云安县| 高州市| 益阳市|