I have made a OLE automation object in Delphi 7 which I'm using in Navision.
The first version of the have this method:
Delphi code:
function Resize(const inputFileName, outputFileName: WideString; height, width: Integer): Integer; safecall;
This works fine when used both in a Delphi program and in Navision.
What the function does is to load a picture file from disk and write it out
to disk in .bmp format, although this is not really important to know.
As I said this works just fine in Navision, where I can load the .bmp file
into a BLOB field in a record so that it can be shown on a form in a
PictureBox. All is well.
Now here is the problem:
Instead of writing the bitmap to disk I want to stream the bitmap image back to the calling program to avoid creating a file on the disk.
I can get the streaming to work just fine when it's a Delphi program that
calls the automation object, but I just can't get it to work when I try to
receive the stream in Navision.
I have tried making the methods in different ways:
Way 1, the output stream is one of the parameters:
Delphi code:
function ResizeToStreamOld(const inputFileName: WideString; out outputStream: IUnknown; height, width: Integer): Integer; safecall;
Way 2, the output stream is the function result:
Delphi code:
function ResizeToStream(const inputFileName: WideString; height, width: Integer; out resultCode: Integer): IUnknown; safecall;
Both of these ways work just fine in a Delphi test program.
But I can't get it to work in Navision.
Perhaps because I'm rather new at Navision and don't really know how to work streams in Navision.
How should it be coded on the Navision side?
Does anyone have any experience with streams in Navision and know how to receive a stream so that it can be put into a BLOB field in a record?
Is Delphi's COM streaming and Navision streams compatible?
Should it be coded in a specific way in Delphi and Navision in order to work between different languages?
I would be thankful for any coding samples you might have that shows how to work with streams between Navision and other languages.
I have searched the web but can't find any examples that apply to this, so
any examples that shows how it should be coded in Navision and in the
automation object is appreciated.
Thanks in advance.
Comments
Without using a diskfile.
A stream is just a bunch of bytes, so is it possible to use another variable type as parameter to receive these bytes and somehow get the bytes into a BLOB field in a record?
So that a PictureBox can display it?