0
votes

I'm writing a CS .net wrapper to be used in a Delphi application and I would like to load images from the "remote" .net lib so I don't need to maintain a "copy" imagelist in Delphi.

Question how do I fetch the imagelist via a TLB?

I think I have 3 options to implement this

  1. on startup of application, fetch imagelist by ref and copy to a local imagelist. This gives me an IUnknown as ref parameter in the TLB, can I use that somehow?
  2. I could use a string/widestring or maybe a stream of some sort, I think that could/would be marshalled as a delphi type.
  3. I could store the imagelist as bitmap and load that in delphi on startup - but who would fancy to do that :)

Any ideas / suggestions a more than welcome.

This is the wrapper method

        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;
          }
}    

This is the Delphi TLB unit

function LoadImageList(var imagelist16: IUnknown; var imagelist32: IUnknown;
                   var ResMsg: WideString; out pRetVal: WordBool): HResult; stdcall;
1
IUnkown cannot be used directly, but can be used as an access point to the interfaces that you do need via QueryInterface. You should look up how to use IUnknown. There are plenty of tutorials on the net, but is probably too broad a topic to present an answer here.Dsm

1 Answers

0
votes

"stdole.IPictureDisp" interface as parameter type should do the trick.

COM Interop & image conversion (via API) : http://blogs.msdn.com/b/andreww/archive/2007/07/30/converting-between-ipicturedisp-and-system-drawing-image.aspx