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
Solved

Component Doesn't Display When Created Dynamically - Delphi Newbie

Posted on 2002-05-17
2
168 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Printing problem 2 102
Need Help Delphi 2010 CheckBox1 Stored value in memo 13 71
Twebbrowser add css to the header 3 28
How to save the image in the .cds File ClientDataSet? 1 22
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 this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

839 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