Delphi

本类阅读TOP10

·分布式网络考试系统原型分析及实现
·游戏外挂设计技术探讨①
·使用HOOK随心监视Windows
·Delphi 水晶报表打包解决
·试题库开发中非文本数据的处理
·如何将几个DBGRID里的内容导入同一个EXCEL表中....的问题
·如何使用Delphi设计强大的服务器程序
·工人线程中关闭窗体的实现
·用DLL方式封装MDI子窗体。
·支持XP下托盘栏气球提示的托盘单元

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
Delphi图象截取编程示例(1)

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

注意,本例在 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;    
       




相关文章

相关软件