?
Solved

Adding components at runtime

Posted on 2007-08-09
2
Medium Priority
?
151 Views
Last Modified: 2013-11-05
I would like to add Timer at runtime.
The OnTimer event should be able to figure out the name of the Timer.
Example:

for I := 0 to 5 do
begin
  with TTimer.Create(Self) do
  begin
    Interval := 1000;
    Name := 'pp' + IntToStr(I);
    Enabled := True;
    OnTimer := TimerG;
  end;
end;

then the Ontimer event:

procedure TForm1.TimerG(Sender: TObject);
begin
  ShowMessage(self.name);
end;

This will show a message saying 'Form1', but I want it to show 'pp0', 'pp1', 'pp2' ... instead. How?

Greetings.
0
Comment
Question by:TonyJix
2 Comments
 
LVL 21

Accepted Solution

by:
ziolko earned 1000 total points
ID: 19661672
try this:
ShowMessage((Sender as TTimer).Name);

ziolko.
0
 
LVL 10

Assisted Solution

by:dinilud
dinilud earned 1000 total points
ID: 19661699
ShowMessage(TTimer(Sender ).Name);
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

850 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