gklux
asked on
Component inside another component...
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
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
If you want it to appear in the Object Inspector, you will have to write a property editor for type TPanel.
(I think)
try declaring the panel as published. i think all published properties of the panel should be visible in the object inspector.
Jo
Jo
ASKER
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
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
ASKER
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
Mike
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.
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.
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(Valu e: 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.
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(Valu
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.
listening :-)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
THANKS A LOT