Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Visual component easy...

Posted on 1999-07-06
4
Medium Priority
?
177 Views
Last Modified: 2010-04-06
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;
0
Comment
Question by:RBertora
[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
  • 2
4 Comments
 
LVL 7

Author Comment

by:RBertora
ID: 1386634
It seems to me that create does not get called , when dropping a component on a form... why is this?
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1386635
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.
0
 
LVL 3

Accepted Solution

by:
Slavak earned 200 total points
ID: 1386636
Hi,

I tried the code, it has a problem if you use the control in design-time only. To solve the problem add reserved word "ovveride" following constructor declaration.
Like this:

 published
  constructor create(AOwner : TComponent); override;  

Regards.

0
 
LVL 7

Author Comment

by:RBertora
ID: 1386637
Simple but perfect answer, thanks!
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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

688 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