Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Loading component properties

Posted on 2015-01-09
1
Medium Priority
?
137 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
[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
1 Comment
 
LVL 14

Accepted Solution

by:
SteveBay earned 2000 total points
ID: 40540320
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

721 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