<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Message</TITLE>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1458" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Ah I see, I realise your problem now. </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>What I was suggesting with regards to the casting,
would be something like this.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>dllobject.tag:=3; (or classname or whatever you
want to use).</FONT></DIV>
<DIV><FONT face=Arial size=2>dllobject.passobject(someobject);</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>inside dll.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>var PanelObject:tpanel;</FONT></DIV>
<DIV><FONT face=Arial size=2>
ButtonObject:tbutton;</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>procedure
passobject(someobject:tobject);</FONT></DIV>
<DIV><FONT face=Arial size=2>begin</FONT></DIV>
<DIV><FONT face=Arial size=2> case someobject.tag
of</FONT></DIV>
<DIV><FONT face=Arial size=2>
1:begin</FONT></DIV>
<DIV><FONT face=Arial size=2>
PanelObject:=tpanel(someobject);</FONT></DIV>
<DIV><FONT face=Arial size=2>
Objecttype:=1;</FONT></DIV>
<DIV><FONT face=Arial size=2>
end;</FONT></DIV>
<DIV><FONT face=Arial size=2>
2:begin</FONT></DIV>
<DIV><FONT face=Arial size=2>
<DIV><FONT face=Arial
size=2>
ButtonObject:=tbutton(someobject);</FONT></DIV>
<DIV><FONT face=Arial size=2>
Objecttype:=3;</FONT></DIV></FONT></DIV>
<DIV><FONT face=Arial size=2>
end;</FONT></DIV>
<DIV><FONT face=Arial size=2>end;</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>function Useditem:tobject;</FONT></DIV>
<DIV><FONT face=Arial size=2>begin</FONT></DIV>
<DIV><FONT face=Arial size=2> case
objecttype of</FONT></DIV>
<DIV><FONT face=Arial size=2>
1:result:=panelobject;</FONT></DIV>
<DIV><FONT face=Arial
size=2>
3:result:=buttonobject;</FONT></DIV>
<DIV><FONT face=Arial size=2>
end;</FONT></DIV>
<DIV><FONT face=Arial size=2>end;</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>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?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>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</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>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...</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>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.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Just some thoughts, hope you sort it
out,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Matt.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=phil@tumonz.co.nz href="mailto:phil@tumonz.co.nz">Phil Middlemiss</A>
</DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=delphi@ns3.123.co.nz
href="mailto:delphi@ns3.123.co.nz">NZ Borland Developers Group - Delphi
List</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Wednesday, September 08, 2004 5:46
PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> Re: [DUG] Passing Objects to a
DLL</DIV>
<DIV><BR></DIV>
<DIV><FONT face=Arial size=2>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).</FONT></DIV>
<DIV><FONT face=Arial size=2>Thanks anyway.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Cheers,</FONT></DIV>
<DIV><FONT face=Arial size=2>Phil.</FONT></DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=matt@ferndigital.com href="mailto:matt@ferndigital.com">Matt
Comb</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=delphi@ns3.123.co.nz
href="mailto:delphi@ns3.123.co.nz">NZ Borland Developers Group - Delphi
List</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Wednesday, September 08, 2004
4:54 PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> Re: [DUG] Passing Objects to a
DLL</DIV>
<DIV><BR></DIV>
<DIV><FONT face=Arial size=2>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.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>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.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>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.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Matt.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=phil@tumonz.co.nz href="mailto:phil@tumonz.co.nz">Phil
Middlemiss</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=delphi@ns3.123.co.nz
href="mailto:delphi@ns3.123.co.nz">NZ Borland Developers Group - Delphi
List</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Wednesday, September 08, 2004
4:47 PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> [DUG] Passing Objects to a
DLL</DIV>
<DIV><BR></DIV>
<DIV><FONT face=Arial size=2>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.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Can anyone shed any light on
this?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Cheers,</FONT></DIV>
<DIV><FONT face=Arial size=2>Phil.</FONT></DIV>
<P>
<HR>
<P></P>_______________________________________________<BR>Delphi mailing
list<BR>Delphi@ns3.123.co.nz<BR>http://ns3.123.co.nz/mailman/listinfo/delphi<BR></BLOCKQUOTE>
<P>
<HR>
<P></P>_______________________________________________<BR>Delphi mailing
list<BR>Delphi@ns3.123.co.nz<BR>http://ns3.123.co.nz/mailman/listinfo/delphi<BR></BLOCKQUOTE>
<P>
<HR>
<P></P>_______________________________________________<BR>Delphi mailing
list<BR>Delphi@ns3.123.co.nz<BR>http://ns3.123.co.nz/mailman/listinfo/delphi<BR></BLOCKQUOTE></BODY></HTML>