Solved

Loading component properties

Posted on 2015-01-09
1
128 Views
Last Modified: 2015-01-13
In 'local system' I have one application running where I save component (TForm) to a file and Load it from another logged-in user.

Thereafter I want to update the Caption/Visible/Color properties every few seconds of few TLabel/TSpeedbutton/TButton.

Using (Controls... as TLabel).Caption work but not for TSpeedbutton.

I Use Delphi Xe2 on all Windows OS

Regards
Allan
0
Comment
Question by:Allan_Fernandes
1 Comment
 
LVL 14

Accepted Solution

by:
SteveBay earned 500 total points
Comment Utility
Different Controls introduce the caption property at different levels of inheritance. If two components use a common ancestor's caption property then casting one component as another component will probably allow access to that component's common property.

In the case of TSpeedButton, "Caption" property is introduced at the TSpeedButton level and therefore should only be accessed by casting as TSpeedbutton.

Try something like :
if Control[I] is TSpeedButton  then
    (Control[I] as TSpeedButton).Caption := 'Blah'
else if Control[I] is TButton  then
    (Control[I] as TButton).Caption := 'Blah'
else if Control[I] is TLabel  then
    (Control[I] as TLabel).Caption := 'Blah'

Open in new window


Sure it's more code but much less likely to cause an access violation.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
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…

744 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

14 Experts available now in Live!

Get 1:1 Help Now