Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 11-23-2006, 12:11 AM
Bharathi Bharathi is offline
Senior Member
 
Join Date: Oct 2006
Posts: 120
Default run time component creation

hi,

to create the component in run time, i need Component parent.

how do i know the parent component of a respective component and what are the things to be added in USES ???
Reply With Quote
  #2  
Old 11-23-2006, 12:15 AM
shanandc shanandc is offline
Senior Member
 
Join Date: Apr 2006
Posts: 115
Default RE: run time component creation

Hello,

R u trying to start creating a component frm a unit file?
U have an option in delphi which allows u to specify its ancestor and the file name..nd so also it wil open up a pas fle with component class ready for u
File->New->Component.
It will display u a dialog for creating a component.
refer delphi help on dialog

Click on accept answer if this solves

Regards,

Shanand Chandradas
Reply With Quote
  #3  
Old 11-23-2006, 12:36 AM
Bharathi Bharathi is offline
Senior Member
 
Join Date: Oct 2006
Posts: 120
Default RE: run time component creation

for example,

i want to use the IBDatabase in Run time. i create it in run time by a button click in such a way.

IBDatabase1 :TIBDatabase.create(self);

and i add DB,IBDatabase in USES.
So,

how to know the Paren name(eg:TIBDatabase) and what are the things added in USES(eg: DB,IBDatabase).
Reply With Quote
  #4  
Old 11-23-2006, 12:47 AM
shanandc shanandc is offline
Senior Member
 
Join Date: Apr 2006
Posts: 115
Default RE: run time component creation

Hi
You mean its class name??
Usually parent is the nothing but the one u pass object in the create constructor.
But i got frm ur example is that u require its class name right??..
u can use the className property to know its class name
ex
var
DB:TIBDatabase;
...
DB:=TIBDatabase.Create(self);
showmessage('class: '+db.ClassName);
showmessage('Parent: ' +db.Owner.Name);
showmessage('Parent Class: ' + db.Owner.className);

To get the class name or parent name all u need is System and Classes

Pls click on "Accept as Answer" if this solves!
Regards,


Shanand Chandradas
Reply With Quote
  #5  
Old 11-24-2006, 01:23 AM
digitiger digitiger is offline
Senior Member
 
Join Date: Jan 2001
Posts: 716
Default RE: run time component creation

I think both of you are bit confused between owner and the parent.

The above two are distinct fields for all the visible controls. While the owner is responsible for memory management related to control being created at runtime, the parent is the one which is responsible for screen painting and message routines.

At the time of creating any control or component, the parameter required is for owner and not parent (atleast in most common ones). So in your case if you are not sure about which name you should specifiy in that parameter then you can either pass it as (self) to point to the current class in which you are creating the new component or you can sometime pass it as (application) .

As for registering the related class or specifying the file name in use class, if you are not sure then just drop one component (of the type which you want to create at run time) and compile the application. Delphi will automatically add the required files in the use clause if that component type is installed. now after that even if you delete that component from your form, still you will have all the required file names in the use clause.

Hope it helps and if it does then do accept the answere
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 08:36 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.