Solved

Component Doesn't Display When Created Dynamically - Delphi Newbie

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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 seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

762 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

20 Experts available now in Live!

Get 1:1 Help Now