Solved

Setting typed properties at runtime?

Posted on 2001-07-25
2
191 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

757 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

19 Experts available now in Live!

Get 1:1 Help Now