RE: Creating Objects using strings
"Luke Young" <[email protected]> Tue, 12 Aug 2003 14:48:13 -0000
| Newsgroups | gmane.comp.lang.delphi.programming |
|---|---|
| Message-ID | <[email protected]> |
The problem is that at the point just before creation the code doesn't explicitly know what class is to be created. So I cannot have a variable in the routine for every possible class. I will have a look at the chapter thanks. Cheers Luke --- In [email protected], "Marcelo Mrack" <mrack@u...> wrote: > This aproach is very good. But, the best way to create objects is > First) Create objects directly > ex.: > var > c: TMyClass; > begin > c: = TMyClass.Create; > Second) Use Interfaces, like your code, but using Classes and Interfaces (see IntfForm, chapter 12 of Mastering Delphi 6 by Cantú) > -----Original Message----- > From: Luke Young [mailto:luke.young@l...] > Sent: terça-feira, 12 de agosto de 2003 10:40 > To: [email protected] > Subject: [Delphi] Creating Objects using strings > > > > The problem: > > I want to create an object of a class that has its class name stored > as a string. > > Currently I do this by using > > initialization > RegisterClass(TMyClassName); > > and then in the routine I use > > tmpClass := FindClass(strClass); > tmpObject := TControlClass(tmpClass).Create(Self); { All classes are > TControlClass based } > > Is there a better way of doing this? I am wondering if Registering the > class has any penalty? or is this the way to go? > > Cheers > > Luke > > > > Yahoo! Groups Sponsor > <http://rd.yahoo.com/M=259395.3614674.4902533.1261774/D=egroupweb/S=1705115= 362:HM/A=1524963/R=0/SIG=12o885gmo/*http://hits.411web.com/cgi-bin/autoredir= ?camp=556&lineid=3614674&prop=egroupweb&pos=HM> > <http://us.adserver.yahoo.com/l?M=259395.3614674.4902533.1261774/D=egroupma= il/S=:HM/A=1524963/rand=424258177> > > CodeCoffer - new Delphi code protection Tool! > http://www.delphicollection.com/public/CodeCoffer.htm > --------------------------------------------------------------- > Unsubscribe:[email protected] > List owner:[email protected] > --------------------------------------------------------------- > > Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service <http://docs.yahoo.com/info/terms/> . > > > > > ____________________ > NOTIFICAÇÃO: > Este email passou pelo controle de conteúdo e está livre de vírus. > Setor de Informática - UNISC > > > > [Non-text portions of this message have been removed] ------------------------ Yahoo! Groups Sponsor ---------------------~--> Buy Ink Cartridges or Refill Kits for Your HP, Epson, Canon or Lexmark Printer at Myinks.com. Free s/h on orders $50 or more to the US & Canada. http://www.c1tracking.com/l.asp?cid=5511 http://us.click.yahoo.com/l.m7sD/LIdGAA/qnsNAA/i7folB/TM ---------------------------------------------------------------------~-> CodeCoffer - new Delphi code protection Tool! http://www.delphicollection.com/public/CodeCoffer.htm --------------------------------------------------------------- Unsubscribe:[email protected] List owner:[email protected] --------------------------------------------------------------- Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/