Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Loading component properties

Posted on 2015-01-09
1
Medium Priority
?
138 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 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

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…
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…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses
Course of the Month13 days, 11 hours left to enroll

963 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