Solved

Component Doesn't Display When Created Dynamically - Delphi Newbie

Posted on 2002-05-17
2
166 Views
Last Modified: 2010-04-04
Hi, created a new component using Delphi 6 which won't display when i call it at run time although it is being created, at least it appears to be when i debug it. Therefore Decided to recreate its class on a blank form and to try and display it when i clicked the form to remove the possibility that it was other code interfering. The object still doesn't appear. i know i`m missing something simple but being new to delphi can't figure it out! Heres my code:


unit TestTimePeriod;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls,Menus;
type
  TForm1 = class(TForm)
    procedure FormClick(Sender: TObject);
    private
      { Private declarations }
    public
      { Public declarations }
  end;

  TIBTTimePeriodRect = class(TShape)
    private
      //Variables
      startTime: Integer;
      endTime: Integer;
      timeCode: string;



    protected

    public
      //Variables

      //Methods
      constructor create(AOwner: TComponent); override;

    published
  end;



var
  Form1: TForm1;

implementation

{$R *.dfm}

  //TIBTTimePeriodRect's Constructor & Destructor
  constructor TIBTTimePeriodRect.create(AOwner: TComponent);
  Begin
    inherited create(AOwner);

    startTime:=0;
    endTime:=0;
    timeCode:='';

  end;




procedure TForm1.FormClick(Sender: TObject);
var
  TP:TIBTTimePeriodRect;
begin

  TP:=TIBTTimePeriodRect.create(self);


  tp.Left:=10;
  tp.width:=100;
  tp.top:=10;
  tp.Height:=25;

  tp.Brush.Color:=clWhite;
  tp.Visible:=true;


  ShowMessage('TimePeriod should be visible');

end;

end.


Do i need to assign the object to the form? Is it something to do with the fact it is a subclass of TShape?

I`ll be Grateful for any help, thanks in advance,

Mick
0
Comment
Question by:mgroarty
2 Comments
 
LVL 4

Accepted Solution

by:
max-hb earned 50 total points
ID: 7016293
Hi!
You simply forgot:

tp.parent:=self

;-)
0
 

Author Comment

by:mgroarty
ID: 7016474
Cheers mate!!! new it would be simple but as per couldn't see the orest for the trees!!
An easy 50pts for ye,eh?

Honestly,thanks again,
Mick

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

863 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now