Solved

Addressing controls created at runtime

Posted on 1998-08-28
7
134 Views
Last Modified: 2012-05-04
Hi,

I am creating a number of controls on a form at runtime. I am storing pointers to these controls in a TList on creation.

How do I use the entries in TList to access the properties and methods of the control or do I even need to do this to access the properties of the controls?

Thanks
0
Comment
Question by:ChrisBerry
  • 3
  • 2
  • 2
7 Comments
 
LVL 7

Expert Comment

by:BlackMan
ID: 1337994
You need to typecast them, like TButton(MyList[1]).Caption. That also means that you need to know what type the objects are, otherwise you can typecast them to the lowest common object and use the properties defined on that object (f.ex. TComponent)
0
 

Author Comment

by:ChrisBerry
ID: 1337995
Thanks, just what I wanted.

Just one thing - why when a property/event like OnMouse... is declared in the heirarchy at the TObject or TWinObject (I forget which) can I only access it at the, say, TEdit level?

Please lock the question so I can hand you the points.

Regards

Chris

0
 

Expert Comment

by:chrismo
ID: 1337996
To your second question - because the lower level components publish these properties that were previously declared public or protected...
0
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.

 

Expert Comment

by:chrismo
ID: 1337997
To your second question - because the lower level components publish these properties that were previously declared public or protected...
0
 

Author Comment

by:ChrisBerry
ID: 1337998
Thanks chrismo,

I wish to reject your answer because BlackMan gave the main answer I was looking for. If he does not lock within the next day or so please feel free to lock again and I will pass the points to you.


0
 
LVL 7

Accepted Solution

by:
BlackMan earned 50 total points
ID: 1337999
You need to typecast them, like TButton(MyList[1]).Caption. That also means that you need to know what type the objects are, otherwise you can typecast them to the lowest common object and use the properties defined on that object (f.ex. TComponent)
0
 

Expert Comment

by:chrismo
ID: 1338000
No problem - I didn't realized I posted twice - I meant to just post a comment as I knew I wasn't answering the main question.
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

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
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.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

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