【问题标题】:Can I instantiate an ActiveX Control directly in a Delphi app, either via TOleContainer or some other way?我可以通过 TOleContainer 或其他方式直接在 Delphi 应用程序中实例化 ActiveX 控件吗?
【发布时间】:2012-09-11 10:52:05
【问题描述】:

TOleContainer 当然可以插入 OLE 对象,如 Word 文档。但它似乎不适用于 ActiveX。当然,我知道 Delphi 创建 ActiveX 包装器的 IDE 能力。如果我想在运行时创建控件而不创建包装器并将其安装到 IDE 中怎么办?

控件已注册,所以unlike this question, I don't need registration-free com。我只需要一些关于如何启动动态 ActiveX 容器的想法或示例。

【问题讨论】:

    标签: delphi activex


    【解决方案1】:

    TOleContainer 与 ActiveX 控件一起使用,您只需将 Activex 控件的正确 ProgID 传递给 CreateObject 方法,然后使用后期绑定访问 ActiveX 的属性。

    查看此示例,该示例在运行时在 TOleContainer 内创建 Windows Media Player ActiveX 控件。

    OleContainer1.CreateObject('Wmplayer.OCX.7', False);
    OleContainer1.OleObject.URL:='F:\Music\Iron Maiden - The number of the beast.mp3';
    OleContainer1.OleObject.Controls.Play;
    

    【讨论】:

    • 哦。铁娘子 - 好多年没听过他们了。现在必须在我的播放列表上复古。 :-)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多