【问题标题】:Load imagelist from CS .net wrapper into Delphi将图像列表从 CS .net 包装器加载到 Delphi
【发布时间】:2016-08-18 09:14:03
【问题描述】:

我正在编写一个用于 Delphi 应用程序的 CS .net 包装器,我想从“远程”.net 库中加载图像,因此我不需要在 Delphi 中维护“复制”图像列表。

问题我如何通过 TLB 获取图像列表?

我想我有 3 个选项来实现这个

  1. 在应用程序启动时,通过 ref 获取 imagelist 并复制到本地 imagelist。这给了我一个 IUnknown 作为 TLB 中的 ref 参数,我可以以某种方式使用它吗?
  2. 我可以使用字符串/宽字符串或某种类型的流,我认为可以/将被编组为 delphi 类型。
  3. 我可以将图像列表存储为位图并在启动时将其加载到 delphi 中 - 但谁愿意这样做:)

欢迎提出任何想法/建议。

这是包装方法

        public bool LoadImageList(ref ImageList imagelist16, ref ImageList imagelist32, ref String ResMsg) 
        {
            ResMsg = "Imagelist could be loaded: ";
            try {
               imagelist16 = null;
               imagelist32 = null;
               if (!_initialized) return false;
               imagelist16 = VideoOS.Platform.UI.Util.ImageList;
               imagelist32 = VideoOS.Platform.UI.Util.ImageList32;
               ResMsg = "Images loaded";
               return true;
            }
          catch (Exception e) {
            ResMsg = ResMsg + e.Message;
            return false;
          }
}    

这是 Delphi TLB 单元

function LoadImageList(var imagelist16: IUnknown; var imagelist32: IUnknown;
                   var ResMsg: WideString; out pRetVal: WordBool): HResult; stdcall;

【问题讨论】:

  • IUnkown 不能直接使用,但可以通过 QueryInterface 用作您需要的接口的访问点。您应该查看如何使用 IUnknown。网上有很多教程,但可能主题太宽泛,无法在这里给出答案。

标签: delphi type-conversion


【解决方案1】:

“stdole.IPictureDisp”接口作为参数类型应该可以解决问题。

COM 互操作和图像转换(通过 API):http://blogs.msdn.com/b/andreww/archive/2007/07/30/converting-between-ipicturedisp-and-system-drawing-image.aspx

【讨论】:

    猜你喜欢
    • 2012-08-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-07
    • 1970-01-01
    • 2016-05-15
    • 2014-04-10
    • 2011-05-12
    相关资源
    最近更新 更多