新书推介:《语义网技术体系》
作者:瞿裕忠,胡伟,程龚
   >>中国XML论坛<<     W3CHINA.ORG讨论区     计算机科学论坛     SOAChina论坛     Blog     开放翻译计划     新浪微博  
 
  • 首页
  • 登录
  • 注册
  • 软件下载
  • 资料下载
  • 核心成员
  • 帮助
  •   Add to Google

    >> 本版讨论SVG, GML, X3D, VRML, VML, XAML, AVALON, Batik等基于XML的图形技术,以及有关GIS的应用。
    [返回] 中文XML论坛 - 专业的XML技术讨论区XML.ORG.CN讨论区 - 高级XML应用『 SVG/GML/VRML/X3D/XAML 』 → [推荐]Delphi利用Adobe ActiveX viewer 监听事件的例子 查看新帖用户列表

      发表一个新主题  发表一个新投票  回复主题  (订阅本版) 您是本帖的第 6873 个阅读者浏览上一篇主题  刷新本主题   树形显示贴子 浏览下一篇主题
     * 贴子主题: [推荐]Delphi利用Adobe ActiveX viewer 监听事件的例子 举报  打印  推荐  IE收藏夹 
       本主题类别:     
     SCYANGYU 帅哥哟,离线,有人找我吗?处女座1971-9-20
      
      
      威望:7
      等级:大四(每天看1小时莱昂氏)
      文章:217
      积分:1281
      门派:XML.ORG.CN
      注册:2005/2/17

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给SCYANGYU发送一个短消息 把SCYANGYU加入好友 查看SCYANGYU的个人资料 搜索SCYANGYU在『 SVG/GML/VRML/X3D/XAML 』的所有贴子 引用回复这个贴子 回复这个贴子 查看SCYANGYU的博客楼主
    发贴心情 [推荐]Delphi利用Adobe ActiveX viewer 监听事件的例子

    Example showing how to receive events in Delphi from Adobe ActiveX viewer
    Delphi利用Adobe ActiveX viewer 监听事件的例子

    这个例子我研究了一下,发现特别好,值得推荐!
    该例子演示了动态生成SVG图形的方法,并能加入事件监测。可惜不知道如何保存动态生成的SVG图形。

    ---------------------------------------
    unit TestUnit;

    interface

    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
       Forms, Dialogs, ActiveX, SVGACTIVEXLib_TLB, StdCtrls, OleCtrls, SvgEXT;

    type
    TForm1 = class(TForm)
       SVGCtl1: TSVGCtl;
       Debug: TMemo;
        Button1: TButton;
        Button2: TButton;
        Label1: TLabel;
        procedure FormCreate(Sender: TObject);
        procedure Button1Click(Sender: TObject);
        procedure Button2Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;

    var
      Form1: TForm1;

    implementation
    {$R *.dfm}


    procedure TForm1.FormCreate(Sender: TObject);
    begin
        Form1.SVGCtl1.setSrc(GetCurrentDir+'\test.svg');
    end;

    procedure TForm1.Button1Click(Sender: TObject);
    begin
      Application.Terminate;
    end;

    procedure TForm1.Button2Click(Sender: TObject);
    var
       ReadyState: integer;
       rcDisp: IDispatch;
       SVGDocument: TSVGDocument;
       SVGRoot, SVGElement, rc: TSVGDocument;
       txtDisp,txtnodeDisp: IDispatch;
       txt: TSVGDocument;
       imgDisp: IDispatch;
       img: TSVGDocument;
       EventListener: TEventListener;
    const NamespaceURI = 'http://www.w3.org/2000/xlink/namespace/';
    begin
      ReadyState:=SVGCtl1.ReadyState;
      if ReadyState<>4 then
        Form1.Debug.Lines.Add('SVG viewer not ready')
      else
      begin
         Form1.Debug.Lines.Add('Adding another click event to 1st rectangle');
         Form1.Debug.Lines.Add('  creating a 2nd rectangle with click event,');
         Form1.Debug.Lines.Add('  a piece of text and and image');
         getMem(disparm.rgvarg,4*SizeOf(TVariantArg));  //allow for max of four args
         SVGDocument:=TSVGDocument.Create(SVGCtl1.getSVGDocument);

           // add a click event to the rectangle from test.svg
         SVGElement:=TSVGDocument.Create(SVGDocument.getElementById('OldRect'));
         EventListener:=TEventListener.Create;
         SVGElement.addEventListener('click',EventListener, false);
         SVGRoot:=TSVGDocument.Create(SVGDocument.getRootElement);

           // define a new rectangle and put click event on it
         rcDisp:=SVGDocument.createElement('rect');
         rc:=TSVGDocument.Create(rcDisp);
         rc.setAttribute('id', 'NewElement');
         rc.setAttribute('x','50');
         rc.setAttribute('y','50');
         rc.setAttribute('height','10');
         rc.setAttribute('width','20');
         rc.setAttribute('style','fill:blue; fill-opacity:0.2; stroke:black');
         rc.addEventListener('click',EventListener, false);
         SVGRoot.appendChild(rcDisp);

           // define a new piece of text
         txtDisp:=SVGDocument.createElement('text');
         txt:=TSVGDocument.Create(txtDisp);
         txt.setAttribute('id', 'TextElement');
         txt.setAttribute('x','70');
         txt.setAttribute('y','80');
         txt.setAttribute('style','font-family:Verdana;font-size:15;stroke:red;fill:red');
         txtnodeDisp:=SVGDocument.createTextNode('Howdy!');
         txt.appendChild(txtnodeDisp);
         SVGRoot.appendChild(txtDisp);

           // define an image
         imgDisp:=SVGDocument.createElement('image');
         img:=TSVGDocument.Create(imgDisp);
         img.setAttributeNS(NamespaceURI,'xlink:href', 'hello.png');
         img.setAttribute('height','36');
         img.setAttribute('width','111');
         img.setAttribute('y','100');
         SVGRoot.appendChild(imgDisp);

         FreeMem(disparm.rgvarg);
         rc.Free;
         txt.Free;
         img.Free;
         SVGRoot.Free;
         SVGElement.Free;
         SVGDocument.Free;
         Button2.Visible:=false;
         Label1.Visible:=true;
      end;
    end;

    end.

    ---------------------------------------
    unit TestUnit;

    interface

    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
       Forms, Dialogs, ActiveX, SVGACTIVEXLib_TLB, StdCtrls, OleCtrls, SvgEXT;

    type
    TForm1 = class(TForm)
       SVGCtl1: TSVGCtl;
       Debug: TMemo;
        Button1: TButton;
        Button2: TButton;
        Label1: TLabel;
        procedure FormCreate(Sender: TObject);
        procedure Button1Click(Sender: TObject);
        procedure Button2Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;

    var
      Form1: TForm1;

    implementation
    {$R *.dfm}


    procedure TForm1.FormCreate(Sender: TObject);
    begin
        Form1.SVGCtl1.setSrc(GetCurrentDir+'\test.svg');
    end;

    procedure TForm1.Button1Click(Sender: TObject);
    begin
      Application.Terminate;
    end;

    procedure TForm1.Button2Click(Sender: TObject);
    var
       ReadyState: integer;
       rcDisp: IDispatch;
       SVGDocument: TSVGDocument;
       SVGRoot, SVGElement, rc: TSVGDocument;
       txtDisp,txtnodeDisp: IDispatch;
       txt: TSVGDocument;
       imgDisp: IDispatch;
       img: TSVGDocument;
       EventListener: TEventListener;
    const NamespaceURI = 'http://www.w3.org/2000/xlink/namespace/';
    begin
      ReadyState:=SVGCtl1.ReadyState;
      if ReadyState<>4 then
        Form1.Debug.Lines.Add('SVG viewer not ready')
      else
      begin
         Form1.Debug.Lines.Add('Adding another click event to 1st rectangle');
         Form1.Debug.Lines.Add('  creating a 2nd rectangle with click event,');
         Form1.Debug.Lines.Add('  a piece of text and and image');
         getMem(disparm.rgvarg,4*SizeOf(TVariantArg));  //allow for max of four args
         SVGDocument:=TSVGDocument.Create(SVGCtl1.getSVGDocument);

           // add a click event to the rectangle from test.svg
         SVGElement:=TSVGDocument.Create(SVGDocument.getElementById('OldRect'));
         EventListener:=TEventListener.Create;
         SVGElement.addEventListener('click',EventListener, false);
         SVGRoot:=TSVGDocument.Create(SVGDocument.getRootElement);

           // define a new rectangle and put click event on it
         rcDisp:=SVGDocument.createElement('rect');
         rc:=TSVGDocument.Create(rcDisp);
         rc.setAttribute('id', 'NewElement');
         rc.setAttribute('x','50');
         rc.setAttribute('y','50');
         rc.setAttribute('height','10');
         rc.setAttribute('width','20');
         rc.setAttribute('style','fill:blue; fill-opacity:0.2; stroke:black');
         rc.addEventListener('click',EventListener, false);
         SVGRoot.appendChild(rcDisp);

           // define a new piece of text
         txtDisp:=SVGDocument.createElement('text');
         txt:=TSVGDocument.Create(txtDisp);
         txt.setAttribute('id', 'TextElement');
         txt.setAttribute('x','70');
         txt.setAttribute('y','80');
         txt.setAttribute('style','font-family:Verdana;font-size:15;stroke:red;fill:red');
         txtnodeDisp:=SVGDocument.createTextNode('Howdy!');
         txt.appendChild(txtnodeDisp);
         SVGRoot.appendChild(txtDisp);

           // define an image
         imgDisp:=SVGDocument.createElement('image');
         img:=TSVGDocument.Create(imgDisp);
         img.setAttributeNS(NamespaceURI,'xlink:href', 'hello.png');
         img.setAttribute('height','36');
         img.setAttribute('width','111');
         img.setAttribute('y','100');
         SVGRoot.appendChild(imgDisp);

         FreeMem(disparm.rgvarg);
         rc.Free;
         txt.Free;
         img.Free;
         SVGRoot.Free;
         SVGElement.Free;
         SVGDocument.Free;
         Button2.Visible:=false;
         Label1.Visible:=true;
      end;
    end;

    end.


       收藏   分享  
    顶(0)
      




    ----------------------------------------------
    http://borland.mblogger.cn/scyangyu/

    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2005/2/26 18:40:00
     
     lch21 帅哥哟,离线,有人找我吗?
      
      
      等级:大一新生
      文章:1
      积分:65
      门派:XML.ORG.CN
      注册:2005/3/27

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给lch21发送一个短消息 把lch21加入好友 查看lch21的个人资料 搜索lch21在『 SVG/GML/VRML/X3D/XAML 』的所有贴子 引用回复这个贴子 回复这个贴子 查看lch21的博客2
    发贴心情 
    能不能将 TEventListener的代码贴出来,非常感谢!
    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2005/4/1 22:03:00
     
     lch21 帅哥哟,离线,有人找我吗?
      
      
      等级:大一新生
      文章:1
      积分:65
      门派:XML.ORG.CN
      注册:2005/3/27

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给lch21发送一个短消息 把lch21加入好友 查看lch21的个人资料 搜索lch21在『 SVG/GML/VRML/X3D/XAML 』的所有贴子 引用回复这个贴子 回复这个贴子 查看lch21的博客3
    发贴心情 
    希望楼主能看到
    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2005/4/8 15:00:00
     
     _phoenix 帅哥哟,离线,有人找我吗?
      
      
      等级:大一(猛啃高等数学)
      文章:25
      积分:153
      门派:XML.ORG.CN
      注册:2005/4/8

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给_phoenix发送一个短消息 把_phoenix加入好友 查看_phoenix的个人资料 搜索_phoenix在『 SVG/GML/VRML/X3D/XAML 』的所有贴子 引用回复这个贴子 回复这个贴子 查看_phoenix的博客4
    发贴心情 
    多谢啊,漫漫研究.
    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2005/4/12 23:16:00
     
     GoogleAdSense
      
      
      等级:大一新生
      文章:1
      积分:50
      门派:无门无派
      院校:未填写
      注册:2007-01-01
    给Google AdSense发送一个短消息 把Google AdSense加入好友 查看Google AdSense的个人资料 搜索Google AdSense在『 SVG/GML/VRML/X3D/XAML 』的所有贴子 访问Google AdSense的主页 引用回复这个贴子 回复这个贴子 查看Google AdSense的博客广告
    2024/5/13 11:46:05

    本主题贴数4,分页: [1]

    管理选项修改tag | 锁定 | 解锁 | 提升 | 删除 | 移动 | 固顶 | 总固顶 | 奖励 | 惩罚 | 发布公告
    W3C Contributing Supporter! W 3 C h i n a ( since 2003 ) 旗 下 站 点
    苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
    78.125ms