Solved

Component Doesn't Display When Created Dynamically - Delphi Newbie

Posted on 2002-05-17
2
172 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
[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 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses
Course of the Month5 days, 3 hours left to enroll

636 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