Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

published property not shown in Object Inspector

Tags:

delphi

My environment: RadStudio XE4 on Windows 7 Pro (32bit).

Difference between property and function or procedures

In the above Q and A, there is a reply saying "More concretely, if you use the Delphi IDE to program, you will see that the published property (-y+ies) will show up in the Object Inspector".

I tried this.

unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs;

type
  TForm1 = class(TForm)
  private
    FSampleProp1: Integer;
    function GetSampleProp1(): Integer;
    procedure SetSampleProp1(val: Integer);
    { Private declaration }
  published
    { Private declaration }
    property SampleProp1: Integer read GetSampleProp1 write SetSampleProp1;
  end;

I expected that I would have "SampleProp1" in the "property" tab of the Object Inspector. But I do not have that one.

Instead, I had the "SampleProp1" in the [Delphi Class Exploroer]" windows.

Is it incorrect that I would have the published property in the Object Inspector?

like image 341
sevenOfNine Avatar asked Apr 04 '14 08:04

sevenOfNine


1 Answers

The Object Inspector shows only properties that are registered with the IDE in a design time package. You have not done that.

So you could include your form in a design time package and register it with a call to RegisterCustomModule. However this could be quite inconvenient if your form is under active development in your application. You might find yourself repeatedly getting out of sync between the design time package and the application.

Another way to apply form wide behaviour changes is to create a non-visual component that you can drop on to your form. The advantage of this approach is that you can change the form to your heart's content and not get out of sync with your design time components.

like image 195
David Heffernan Avatar answered Sep 30 '22 18:09

David Heffernan