If you want to build in extra safety precautions (which you should, since you never really know how the code is going to be called in the future) you could use the Supports method (in SysUtils I think):

procedure Add(AValue : OLEVariant): Integer;
var
  iList : IListInterface;  // or whatever the interface is
begin
  if Supports(AValue, IListInterface, iList) then
    begin
    //do stuff with iList
    end;
end;

Note the use of interfaces - the TAOleCoordinateList should be handled as an interface once it's created (otherwise it will self destroy, being a referenced object) so you should be passing it in to the Add method as an interface (whether as an OLEVariant of variant type interface or just as the straight interface defined for that object). You should also be adding it to an IInterfaceList instead of a TList.

Phil.

Todd Martin wrote:
Hi Andrew
 
That looks like a Softtech class name.
 
Make your TAOleCoordinate implement a IOleCoordinate interface and TAOleCoordinateList.Add(AValue : IOleCoordinate) : Integer
 
You can cast the interface from IDispatch using QueryInterface()
 
Todd.
 
----- Original Message -----
Sent: Monday, June 12, 2006 8:57 PM
Subject: [DUG] (no subject)

Hi guys,

I have a quick question related to some automation work I am doing and hoped that one of you may be able to shed light.  Anyway I have created a new OleCoordinate class defined as TAOleCoordinate = class(TAutoObject); and have created a related list class defined as TAOleCoordinateList = class(TAutoObject);

I have added a method to TAOleCoordinateList called .Add(AValue: OLEVariant): Integer which attempts to add AValue to a TList object.  The problem is that I don’t know how to type cast OLEVariant to TAOleCoordinate (even though I know it is that object because I created it as such and passed it into this method). 

Anyone able to help me in this matter?

Cheers,

Andrew

 

BTW - This is in Delphi 5.

 


_______________________________________________
Delphi mailing list
[email protected]
http://ns3.123.co.nz/mailman/listinfo/delphi


No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.8.3/361 - Release Date: 11/06/2006

No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.394 / Virus Database: 268.8.3/361 - Release Date: 11/06/2006

_______________________________________________ Delphi mailing list [email protected] http://ns3.123.co.nz/mailman/listinfo/delphi


begin:vcard
fn:Phil Middlemiss
n:Middlemiss;Phil
org:Vision Software, MTS Ltd
email;internet:[EMAIL PROTECTED]
title:Project Leader
tel;work:+64 7 3480001
tel;cell:+64 27 4592648
x-mozilla-html:TRUE
url:http://www.tumonz.co.nz
version:2.1
end:vcard

_______________________________________________
Delphi mailing list
[email protected]
http://ns3.123.co.nz/mailman/listinfo/delphi

Reply via email to