Re:---> Object Question <----
Quote
In article <49b6ev$...@news.scruz.net> Chris Haidinyak <chr...@alpha.techspecs.com> writes:
>From: Chris Haidinyak <chr...@alpha.techspecs.com>
>Subject: ---> Object Question <----
>Date: 27 Nov 1995 02:06:23 GMT
>Hi,
> I am trying to create a linked list of classes but it's not working. Is
>this possible in Delphi? I haven't been able to find a source which does this
>yet; all examples explicitly use variables to instanciate a class. I want to
>be able to instanciate a class using a pointer like Borland 7.0. Will someone
>please point me in the right direction by either a post or EMAIL, thanks.
>--
> Chris Haidinyak
> chr...@alpha.techspecs.com
Well, you could use tlist, as provided in "classes". This is list of pointers
- a limitation is that it has a max number of members of 8 or 16k, I can
never remember. Usually it's enough.
Beacuse it is list of pointers, you can typecast anyaddress on, and stash the
address. You can the typecast it when unloading, and use delphi type info
functions to work out what class it was. for example :
var
anyform : tform;
aedit : tedit;
alabel : tlable;
dlist : tlist;
typestr : string;
begin
dlist := tlist.create;
{assume the other variables are created elsewhere}
dlist.add(pointer(anyform));
dlist.add(pointer(aedit));
dlist.add(pointer(alable));
typestr := tcontrol(dlist[0]).classname; {typestr should be 'tform'}
typestr := tcontrol(dlist[2]).classname; {typestr should be 'tlable'}
dlist.free;
end;
This is off the top of my head, but should show the idea.
Boris Ingram, Cyborg Software
boris...@iafrica.com
http://www.pcb.co.za/users/borising/cyborg.htm