Solved

Setting typed properties at runtime?

Posted on 2001-07-25
2
196 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
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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Suggested Solutions

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…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

829 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