We help IT Professionals succeed at work.

Delphi: own component tForm and published properties

formi
formi asked
on
Medium Priority
155 Views
Last Modified: 2019-08-08
Hi

I will make an own form like this and save it in myForms:
type
  TMyForm = class(TForm)
  private
    FmyInteger : integer;
  public
  published
    property myInteger: integer read FmyInteger write FmyInteger default 0;
  end;

Open in new window


When I make a new form I can not see the new property. How I have to do?
unit myUnit;
  
  interface
    uses myForms;


type
    TF_MyForm = class(tMyForm)
    private
    ……..

    end;


var
F_myForm : TF_MyForm;


implementation

end.

Open in new window



I can use this property myInteger in code but I can not see it in the designer. How to do? Thanks, Peter
Comment
Watch Question

Sinisa VukSoftware architect
CERTIFIED EXPERT
Top Expert 2012

Commented:
This is how it works. I wonder why you need this at first place?
Sometimes it is better to do some in code rather than i design time via properties.
Lets suppose - someone can change your app to act differently - just by modifying properties in resource editor.

Author

Commented:
As I wrote I know that I can do it this way. But it should be possible to make my own properties also in a form as in other components.
Software architect
CERTIFIED EXPERT
Top Expert 2012
Commented:
It is ok to add new properties....But cannot see any benefit from this.
Please, consume this (rather old) article on how to register form properties. Might help but it is not simple task after all.