RBertora
asked on
Visual component easy...
A simple component that descends from twincontrol, I want to be able to see the label within this component as part of the constructor..
What is wrong?
type
TREdit = class(TWinControl)
private
FBorderStyle : TBorderStyle;
FAutoSize : Boolean;
FAutoSelect : Boolean;
FHideSelection : Boolean;
{ Private declarations }
protected
FLabel : TLabel;
{ Protected declarations }
public
{ Public declarations }
published
constructor create(AOwner : TComponent);
destructor Destroy; override;
{ Published declarations }
end;
constructor TREdit.create(AOwner: TComponent);
const
EditStyle = [csClickEvents, csSetCaption, csDoubleClicks, csFixedHeight];
begin
inherited Create(AOwner);
if NewStyleControls then
ControlStyle := EditStyle else
ControlStyle := EditStyle + [csFramed];
Width := 121;
Height := 25;
TabStop := True;
ParentColor := False;
FBorderStyle := bsSingle;
FAutoSize := True;
FAutoSelect := True;
FHideSelection := True;
FLabel := TLabel.Create(Self);
FLabel.Parent := TWinControl(Self);
FLabel.top := 10;
FLabel.left := 10;
FLabel.Caption := 'Hello';
FLabel.Visible := True;
end;
What is wrong?
type
TREdit = class(TWinControl)
private
FBorderStyle : TBorderStyle;
FAutoSize : Boolean;
FAutoSelect : Boolean;
FHideSelection : Boolean;
{ Private declarations }
protected
FLabel : TLabel;
{ Protected declarations }
public
{ Public declarations }
published
constructor create(AOwner : TComponent);
destructor Destroy; override;
{ Published declarations }
end;
constructor TREdit.create(AOwner: TComponent);
const
EditStyle = [csClickEvents, csSetCaption, csDoubleClicks, csFixedHeight];
begin
inherited Create(AOwner);
if NewStyleControls then
ControlStyle := EditStyle else
ControlStyle := EditStyle + [csFramed];
Width := 121;
Height := 25;
TabStop := True;
ParentColor := False;
FBorderStyle := bsSingle;
FAutoSize := True;
FAutoSelect := True;
FHideSelection := True;
FLabel := TLabel.Create(Self);
FLabel.Parent := TWinControl(Self);
FLabel.top := 10;
FLabel.left := 10;
FLabel.Caption := 'Hello';
FLabel.Visible := True;
end;
Well, I see no errors in your code. And create DOES get called! You can be sure of that!
So now where is the problem? Hmm. Have you tried (only for testing) something like this:
FLabel.Parent:=Application .MainForm;
Perhaps you see something now?
Sorry, don't have the time right now to test it myself.
Regards, Madshi.
So now where is the problem? Hmm. Have you tried (only for testing) something like this:
FLabel.Parent:=Application
Perhaps you see something now?
Sorry, don't have the time right now to test it myself.
Regards, Madshi.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Simple but perfect answer, thanks!
ASKER