Solved

Show a label on a form created at runtime

Posted on 1998-06-18
2
165 Views
Last Modified: 2010-04-04
At runtime a have created a form. How can I create a label on this form at runtime so a can display a message.

0
Comment
Question by:lpd
2 Comments
 
LVL 3

Accepted Solution

by:
Pegasus100397 earned 200 total points
ID: 1353863
lpd,

 Put a label on the form, set it's caption to blank (nothing) so it does not show any text. At runtime simply assign a value to the Caption of the Label with something like:

Label1.Caption := 'Hi There!';

Good luck with your project!
Pegasus
0
 
LVL 3

Expert Comment

by:rickpet
ID: 1353864
Okay...you can also create your label at runtime...



type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    Label1 : TLabel;
    procedure MyClick(Sender: TObject);
  end;

var
  Form1: TForm1;


implementation

{$R *.DFM}

procedure TForm1.MyClick(Sender: TObject);
begin
  ShowMessage('Hello');
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
Label1 := TLabel.create(self);
with Label1 do
begin
  parent := self;  //or the form/panel...
  top := 10;
  left := 20;
  caption := 'My Message';
  onclick := myClick;
  show;
end;
end;

end.

Rick

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
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…

757 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

17 Experts available now in Live!

Get 1:1 Help Now