Solved

Setting typed properties at runtime?

Posted on 2001-07-25
2
198 Views
Last Modified: 2010-04-06
Apologies if this question has already been asked somewhere but in that the search function is not fully operational I am unable to search extensively.  Anyway, I need to set the properties of a label at runtime. eg. MyLabel.Font.Color  
The information needed to set the colour is held in a string which is read in from a text file at runtime.  The text in the string is clRed and I'm trying to use it while dynamically creating the label component.  Delphi seems to complain about a type mismatch (TColor and string) and I'm not entirely sure how to get around it.
(Incidentally - it's not actually the colour of text that I'm trying to change, it's a custom component which I created myself and so this is an easier example to explain!)
Any ideas would be greatly appreciated.
Thanks,
Xanthe
0
Comment
Question by:xanthe
[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
2 Comments
 
LVL 9

Accepted Solution

by:
ITugay earned 50 total points
ID: 6316689
Hi xanthe@lc,

Delphi help:

function StringToColor(const S: string): TColor;
Description

Call StringToColor to reverse the translation performed by ColorToString. This method is useful for converting the strings entered by the user into useable TColor values.

The S parameter can be either the name of a built-in color constant such as 'clBtnFace', or the string representation of a valid TColor value such as '$02FF8800'.  StringToColor returns the TColor value that corresponds to the S parameter.

Note:     If the string identifier can only be the name of a color constant, use IdentToColor instead.
0
 

Author Comment

by:xanthe
ID: 6316838
Brilliant!  I see however, that the question I asked was not as straight forward as I had thought.  You will notice that I said that the actual application was not to do with colour but with a custom component I have written, I see now that I will have to modify the code I have written for this component to allow it to have a function to change between a string and a TArrowType(a thing I use in my component)....although how I do that - no idea?!  Anyway, I'll have a try and thanks again for your help and your quick response!
Xanthe
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

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 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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
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…

729 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