Link to home
Start Free TrialLog in
Avatar of DCLSyntect
DCLSyntect

asked on

Adding Property to component - what am I doing wrong

I am trying to add a property to a component, so I can set it in the object inspector at design time, but I can't get the property to appear.

Here is a simple example using a TButton descendant.

type
  TbtnPaySysButton = class(TButton)
  private
    { Private declarations }
    flPassEnabled: boolean;
  protected
    { Protected declarations }
  public
    { Public declarations }
    constructor Create(AOwner: TComponent); override;
  published
    { Published declarations }
    property lPassEnabledToControls: boolean read flPassEnabled write flPassEnabled;  
  end;

Why can't I see the lPassEnabledToControls property in the object inspector?


Avatar of jbshumate
jbshumate

How are you creating the component.  To use the object inspector the component needs to be a design time component.  If you are dynamically creating it then you will not be able to see it.  To make it a design time component you must register it with the ide.  The help file can give you specific instructions for how to do this depending on which version of delphi you have.
Avatar of DCLSyntect

ASKER

I am using Delphi 7

The components are registered on the palette so I can drop them on forms - is that what you meant?
Hi DCLSyntect
all seems fine in code.

try to right mouse click on object inspector bottom line.
follow "view" submenu and check all positions.

____
Igor
Thanks for your help - it seems to be working now for the TButton.  Does this also work for a frame or form?  I originally encountered this problem on a form & frame, and copied the code from there to the button.
ASKER CERTIFIED SOLUTION
Avatar of Igor UL7AAjr
Igor UL7AAjr
Flag of Kazakhstan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks ITugay

I don't see this procedure in the help anywhere.
I assume it replaces RegisterComponent. (?)

Where does the form appear in the IDE?
procedure located in DesignIntf unit.
Do not forget to create .dpr and then add 'designide.dcp' to 'requires' section.

____
Igor
Do not forget to place your form to object repository ('right mouse click on form and 'add to repositroy...')
your form will be available in 'File | New | Other' Delphi menu
under the tab with name you gave while adding the form to repository.
Thanks ITugay

I ran into problems not being able to find Proxies.pas after adding DesignIntf & Designers to my Users clause

Where to I add to the "requires" section of a dpr ?

I'm sorry, I mean .dpk file.

>> I ran into problems not being able to find Proxies.pas .....

There is a liitle bit difficult to explan at once how to build designtime + runtime packages. I will send you some links with explanations. I just need to recall location. Just a moment.

____
Igor


Thanks ITugay

It took a while but all appears to be working now
Hi again

I have another question.
My properties are visible on descendant classes of forms & frames, but not on the original class.

EG:  MYFrame has a property lPassEnabled.
This is not shown in the object inspector for MyFrame, but when I create a new frame MyNewFrame based on MyFrame, the property is visible in the object inspector for MyNewFrame.

Is this normal?
Do I have to initialise the property in the form / frame create procedure?  If so, when does a user change to the property take affect?
Hi DCLSyntect
seems you have to inherit your form from objectrepository (not copy).
not sure about this.

___
Igor