views:

316

answers:

2

I am trying to add a custom property to a base form that can be accessed via the Delphi property editor. If I simply add the property as I would with a standard component the property won't show up in the property editor. Here's what I tried:

unit TestForm;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;

type
  TfrmEasyIPBase = class(TForm)
  private
    FTest: String;
  public
    { Public declarations }
  published
    property Test: String read FTest write FTest;
  end;

var
  frmEasyIPBase: TfrmEasyIPBase;

implementation

{$R *.dfm}

end.

Do I have to register the property at some point?

+3  A: 

RegisterCustomModule should do the trick.

Ulrich Gerhardt
That's right. Here's a nice article about it: http://www.mustangpeak.net/ota_publishedprop_forms.htm
TOndrej
This did the trick. The article is detailed, but the only part I really needed was RegisterCustomModule. I simply added "RegisterCustomModule(TfrmEasyIPBase, TCustomModule);" to my register unit and everything now works perfectly :)
norgepaul
A: 

I don't have access to delphi right now but try adding your TForm descant to your project, add new form, edit the new form's pas file so it will look like

TMyNewForm = Class(TfrmEasyIPBase)

Also edit MyNewForm's DFM file - change object MyNewForm to inherit MyNewForm

Ertugrul Tamer Kara