Title: Message
Ah I see, I realise your problem now.
 
What I was suggesting with regards to the casting, would be something like this.
 
dllobject.tag:=3; (or classname or whatever you want to use).
dllobject.passobject(someobject);
 
inside dll.
 
var PanelObject:tpanel;
     ButtonObject:tbutton;
 
procedure passobject(someobject:tobject);
begin
    case someobject.tag of
        1:begin
            PanelObject:=tpanel(someobject);
            Objecttype:=1;
        end;
        2:begin
            ButtonObject:=tbutton(someobject);
            Objecttype:=3;
        end;
end;
 
function Useditem:tobject;
begin
        case objecttype of
            1:result:=panelobject;
            3:result:=buttonobject;
        end;
end;
 
If you do it this way, then statements such as if Useditem is twhatever, should work, actually after having read your last email, Im not so sure now?
 
I realise this is very limited because you have to hard code the dll to handle specific object types. If you had say 3 different types of objects
 
I may be suggesting things that don't suit what you are trying to achieve, because Im not sure on what types of objects you are passing through, how many different types there are, whether the number of types of these would change etc...
 
For example if the object type was one of your own, I would tend to suggest a rider class that would pass all the information on to the dll in the form of a stream. I have routines that does this, and then reads the object type from the stream and then applies the appropriate reader and writer class, but it would depend completely on what you were trying to achieve. It still requires having to write an interface to each object type though.
 
Just some thoughts, hope you sort it out,
 
Matt.
 
----- Original Message -----
Sent: Wednesday, September 08, 2004 5:46 PM
Subject: Re: [DUG] Passing Objects to a DLL

Hi Matt, casting doesn't actually work when you are trying to compare class types since you don't know what class you have anyway. The tag idea may as well just be the the classname which is what we use as a workaround anyway. If an object is passed into a dll it's fine since it shares the same application space, but I think the issue is with the run time type information that Delphi uses. For example if I use the debugger to have a look at a class variable passed into a dll, it doesn't give the classname, it give something like TClass($4F801) (except a real memory address).
Thanks anyway.
 
Cheers,
Phil.
----- Original Message -----
From: Matt Comb
Sent: Wednesday, September 08, 2004 4:54 PM
Subject: Re: [DUG] Passing Objects to a DLL

Hey Phil, as you know doubt know, passing any type of memory around that is dynamic (e.g. string) as apposed to static (e.g. integer) is not a good idea. I haven't looked but maybe this class information uses strings to store different things, and therefore is unreliable.
 
How many different types of object are you passing through? could you perhaps set the object tag value (e.g. tag=1 = twhatever tag=2 = twhatever2 and then cast type within the dll? ) This would mean though that you would have to upgrade your dll if you want to support any additional type of objects.
 
By the way, I would recommend you not doing this at all. I would pass what information you need from the object through in a static object type, create an object of the type required within the dll and do what you have to do, but of course that would completely depend on the type of object you are throwing around.
 
Matt.
 
----- Original Message -----
Sent: Wednesday, September 08, 2004 4:47 PM
Subject: [DUG] Passing Objects to a DLL

When an object is passed to a DLL it comes across fine and all properties and methods can be accessed, but somehow the class information gets handled differently. Using the "is" comparison fails when it should work - even InheritsFrom doesn't work. We've got around this in the past by using a recursive routine to compare class/ancestor names but I'm beginning to wonder if there is a trick that I have missed somewhere.
 
Can anyone shed any light on this?
 
Cheers,
Phil.


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


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


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

Reply via email to