Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Component Doesn't Display When Created Dynamically - Delphi Newbie

Posted on 2002-05-17
2
Medium Priority
?
177 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 200 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

Technology Partners: 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

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

885 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