IPicture assigment problem
All,
I am using the 'MS Forms 2.0 Image' activeX control dynamically added to a
HTML page viewed in the MS DHTML ActiveX control and want to assign a user
selected image to the control so I can save the resultant HTML page,
(including images) as a single file.
The image activeX has an IImage interface which has a Set_Picture method
that takes an IPictureDisp interface. I create an object with an
IPictureDisp interface via the API call OleLoadPicturePath, (more on that
later), but when I try and assign this to the image control via the
Set_Picture method I always get a floating point exception.
I thought I had found the problem when I found and old news group repy from
Danny Thorpe that the OleLoadPicture functions that were implemented in
OlePro32.dll had been superseeded by functions in OleAut32.dll and this
certainly seems to be the case as functions documented in MSDN are not
implemented in OLEPRO32.DLL. However in Delphi 5s ActiveX unit you will see
that these functions are still linking to OLEPRO32.DLL and not
OLEAUT32.DLL, (Dannys message was dated 1997 so it looks like these have
slipped throuh the net). All this was related to some floating point errors.
Anyway i redeclared the OLE... calls as MyOle... from OLEAUT32.DLL but still
get the error.
Some same code follows but this is driving me nuts at the moment and I would
really appreciate some ideas.
Cheers,
Norm.
P.S you will need to generrate the typelib from the MS forms library to get
the IImage interface etc.
var
TheObject : IHTMLObjectElement;
TheImg : IImage;
ThePicture : IPicture;
ThePictureDisp : IPictureDisp;
begin
{ Find the control on the HTML page }
TheObject := DHTMLEdit1.Dom.all.item('Image1', EmptyParam) as
IHTMLObjectElement;
{ Get its IImage interface }
OleCheck(TheObject.QueryInterface(IImage, TheImg));
{ Create a picture COM object and get its IPicture interface using my
version of the API call }
OleCheck(MyOleLoadPicturePath('c:\winnt\winnt256.bmp', TheObject, 0, 0,
IPicture, ThePicture));
{ Get the IPictureDisp interface }
OleCheck(ThePicture.QueryInterface(IPictureDisp, ThePictureDisp));
{ Try and assign but get the error }
TheImg.picture := ThePictureDisp;