[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Component inside another component...

Posted on 2001-08-09
10
Medium Priority
?
309 Views
Last Modified: 2010-04-06
Hi all.

Here is my question : I'am writing an component than owns a TPanel(called borderPanel). I would like the user being abble to access to all properties of the borderPanel within the Object Inspector.
The final goal should be something like the font property.

How should I declare the BorderPanel property ?

hoping i was clear...

Regards

Mike
0
Comment
Question by:gklux
  • 3
  • 2
  • 2
  • +3
10 Comments
 
LVL 5

Expert Comment

by:scrapdog
ID: 6367473
If you want it to appear in the Object Inspector, you will have to write a property editor for type TPanel.
0
 
LVL 5

Expert Comment

by:scrapdog
ID: 6367478
(I think)
0
 
LVL 3

Expert Comment

by:nnbbb09
ID: 6367608
try declaring the panel as published. i think all published properties of the panel should be visible in the object inspector.

Jo
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:gklux
ID: 6367650
first of all, thanks for interesting into my question.

scrapdog : I did something like this few years ago, and as far as I remember, there is no need to write a poperty editor, but off course, no way to get this previous source neither as remember how i did...


nnbbb09 : sorry, it doesn't works.


regards

Mike
0
 

Author Comment

by:gklux
ID: 6367661
note : I remember where I have learned how to do : it was in the book "secrets d'exerts" (maybe english title was Experts secrets) as far as i remember the author is Dick Lantim. But i don't have this book anymore... if somebody may have this.

Mike
0
 
LVL 1

Expert Comment

by:trex_fire
ID: 6368052
You can redeclare your TPanel and redeclare the properies you want in the published section like:

type
  MyPanel = class(TPanel)
  published
   property Prop1;
   property Prop2;
   property Prop3;
   property Prop4;
   property Prop5;
  end;

This way you only change the visibility of your properties and keep a functionnal TPanel that you can customise on need.
0
 
LVL 9

Expert Comment

by:ITugay
ID: 6368178
Hi gklux,

to make "included" control's property visible in object inspector while you are editing "parent" control you should build some inteface object derived from TPersistent.


here is small sample:

type
  TWinCtlProp = class(TPersistent)
  private
    FWinControl: TWinControl;
    // width
    function GetWidth: Integer;
    procedure SetWidth(V: Integer);
    // height
    procedure SetHeight(Value: Integer);
    function GetHeight: Integer;
    // rest of Get... Set...
  published
    property Width: Integer read GetWidth write SetWidth;
    property Height: Integer read GetHeight write SetHeight;
    // .... rest of properties
  end;

  // here is your own control that has internal TEdit
  TPanel1 = class(TPanel)
  private
    FEdit: TEdit;
    FProp: TWinCtlProp;
  public
    constructor Create(O: TComponent); override;
    destructor Destroy; override;
  published
    property EditProp: TWinCtlProp read FProp;
  end;


implementation


//------------------------------------------------------------------------------
function TWinCtlProp.GetWidth: Integer;
begin
  Result := FWinControl.Width;
end;

procedure TWinCtlProp.SetWidth(V: Integer);
begin
 FWinControl.Width := V;
end;

procedure TWinCtlProp.SetHeight(Value: Integer);
begin
  FWinControl.Height := Value;
end;

function TWinCtlProp.GetHeight: Integer;
begin
  Result := FWinControl.Height;
end;

//------------------------------------------------------------------------------
constructor TPanel1.Create(O: TComponent);
begin
  inherited;
  FEdit := TEdit.Create(Self);
  FEdit.Parent := Self;

  FProp := TWinCtlProp.Create;
  FProp.FWinControl := FEdit;
end;

destructor TPanel1.Destroy;
begin
  FProp.Free;
  FEdit.Free;
  inherited;
end;


-----
Igor.
0
 
LVL 5

Expert Comment

by:Gwena
ID: 6370253
listening :-)
0
 
LVL 9

Accepted Solution

by:
ITugay earned 200 total points
ID: 6372638
hi Gwena,

seems you are interesting in it, so, here is my "secret"  way to show all "subcomponents" properties in object inspector and store it into .DFM file.

Enjoy :-)

---------
Igor


uses
  ....DsgnIntf.....

type
  TMyPanel = class(TPanel)
  private
    FEdit: TEdit;
  protected
    procedure WriteEditBin(Stream: TStream);
    procedure ReadEditBin(Stream: TStream);
    procedure DefineProperties(Filer: TFiler); override;
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
  published
    property Edit: TEdit read FEdit;
  end;


procedure Register;

implementation

procedure Register;
begin
  // changing property editor for Edit, it allow you to see and modify
  // all components property in object inspector by the same way as for TFont
  RegisterPropertyEditor(TypeInfo(TEdit), TMyPanel, 'Edit', TClassProperty);

  RegisterComponents('Samples', [TMyPanel]);
end;


constructor TMyPanel.Create(AOwner: TComponent);
begin
  inherited;
  FEdit := TEdit.Create(Self);
  FEdit.Parent := Self;
end;

destructor TMyPanel.Destroy;
begin
  FEdit.Free;
  inherited;
end;

procedure TMyPanel.WriteEditBin(Stream: TStream);
begin
  Stream.WriteComponent(FEdit);
end;

procedure TMyPanel.ReadEditBin(Stream: TStream);
begin
  Stream.ReadComponent(FEdit);
end;

procedure TMyPanel.DefineProperties(Filer: TFiler);
begin
  inherited;
  // here is the way to store all properties of Edit in .DFM file
  // as you see, property name is "FEdit", it should be any other name,
  // but not the same as published property name.
  Filer.DefineBinaryProperty('FEdit', ReadEditBin, WriteEditBin, true);
end;
0
 

Author Comment

by:gklux
ID: 6378676
THANKS A LOT
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question