记住哦,本站网址是:http://www.7139.com
梦幻网络
导航图标
您现在的位置: 梦幻网络 >> 技术学院 >> 网页设计 >> Script >> 正文

Delphi图象截取编程示例(1)

来源:互联网 收集:梦幻网络 本站网址:www.7139.com 点击数: 【字体:减小 增大


注意,本例在 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;
(完)计算机基础教程网


Google
【更新时间:2006-7-14 7:51:41】【打印此文】【关闭窗口
搜索