?
Solved

Component inside another component...

Posted on 2001-08-09
10
Medium Priority
?
303 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: 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!

 

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

Independent Software Vendors: 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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

770 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