Link to home
Start Free TrialLog in
Avatar of RBertora
RBertoraFlag for United Kingdom of Great Britain and Northern Ireland

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;
Avatar of RBertora
RBertora
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

It seems to me that create does not get called , when dropping a component on a form... why is this?
Avatar of Madshi
Madshi

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.
ASKER CERTIFIED SOLUTION
Avatar of Slavak
Slavak

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Simple but perfect answer, thanks!