Solved

Saving/Loading TColor - Ini's and Strings.

Posted on 2000-05-05
7
251 Views
Last Modified: 2010-04-04
In my app's preferences/display section, I'm trying to save colors for different kinds of text that will be added to my richedit.

I'm using a standard colordialog, and all I want is to select the color, stick it in a string, save the string to an ini file, and when the app is loaded, I need to load the string from the ini and apply it to RichEdit1.Selattributes.Color

I've tried just using IntToStr on the colors and StrToInto when applying them back to selattributes, but it's not working!

Anyone?

-Psylord
0
Comment
Question by:Psylord
  • 3
  • 2
  • 2
7 Comments
 

Author Comment

by:Psylord
ID: 2782800
Adjusted points from 0 to 10
0
 
LVL 15

Expert Comment

by:simonet
ID: 2783213

Typecast the TColor variable to Longint and then call IntToStr.

Alex
0
 
LVL 1

Expert Comment

by:rowisoft
ID: 2783659
Hy!

I've found this in one of my programms...
Look:

     if TEdit(Sender).Color = clAqua then Form2.Edit12.Text := 'Aqua' else
     if TEdit(Sender).Color = clBlack then Form2.Edit12.Text := 'Black' else
     if TEdit(Sender).Color = clBlue then Form2.Edit12.Text := 'Blue' else
     if TEdit(Sender).Color = clDkGray then Form2.Edit12.Text := 'DkGray' else
     if TEdit(Sender).Color = clGreen then Form2.Edit12.Text := 'Green' else
     if TEdit(Sender).Color = clLime then Form2.Edit12.Text := 'Lime' else
     if TEdit(Sender).Color = clLtGray then Form2.Edit12.Text := 'LtGray' else
     if TEdit(Sender).Color = clMaroon then Form2.Edit12.Text := 'Maroon' else
     if TEdit(Sender).Color = clNavy then Form2.Edit12.Text := 'Navy' else
     if TEdit(Sender).Color = clOlive then Form2.Edit12.Text := 'Olive' else
     if TEdit(Sender).Color = clPurple then Form2.Edit12.Text := 'Purple' else
     if TEdit(Sender).Color = clRed then Form2.Edit12.Text := 'Red' else
     if TEdit(Sender).Color = clSilver then Form2.Edit12.Text := 'Silver' else
     if TEdit(Sender).Color = clTeal then Form2.Edit12.Text := 'Teal' else
     if TEdit(Sender).Color = clWhite then Form2.Edit12.Text := 'White' else
     if TEdit(Sender).Color = clYellow then Form2.Edit12.Text := 'Yellow' else
     if TEdit(Sender).Color = clActiveCaption then Form2.Edit12.Text := 'ActiveCaption' else
     if TEdit(Sender).Color = clBackground then Form2.Edit12.Text := 'Background' else
     if TEdit(Sender).Color = clInActiveCaption then Form2.Edit12.Text := 'InActiveCaption' else
     if TEdit(Sender).Color = clMenu then Form2.Edit12.Text := 'Menu' else
     if TEdit(Sender).Color = clWindow then Form2.Edit12.Text := 'Window' else
     if TEdit(Sender).Color = clMenuText then Form2.Edit12.Text := 'MenuText' else
     if TEdit(Sender).Color = clWindowText then Form2.Edit12.Text := 'WindowText' else
     if TEdit(Sender).Color = clCaptionText then Form2.Edit12.Text := 'CaptionText' else
     if TEdit(Sender).Color = clActiveBorder then Form2.Edit12.Text := 'ActiveBorder' else
     if TEdit(Sender).Color = clInActiveBorder then Form2.Edit12.Text := 'InActiveBorder' else
     if TEdit(Sender).Color = clAppWorkSpace then Form2.Edit12.Text := 'AppWorkSpace' else
     if TEdit(Sender).Color = clHighlight then Form2.Edit12.Text := 'Highlight' else
     if TEdit(Sender).Color = clHighlightText then Form2.Edit12.Text := 'HightlightText' else
     if TEdit(Sender).Color = clBtnFace then Form2.Edit12.Text := 'BtnFace' else
     if TEdit(Sender).Color = clBtnShadow then Form2.Edit12.Text := 'BtnShadow' else
     if TEdit(Sender).Color = clGrayText then Form2.Edit12.Text := 'GrayText' else
     if TEdit(Sender).Color = clBtnText then Form2.Edit12.Text := 'BtnText'else
     if TEdit(Sender).Color = clInactiveCaptionText then Form2.Edit12.Text := 'InActiveCaptionText' else
     if TEdit(Sender).Color = clBtnHighlight then Form2.Edit12.Text := 'BtnHighlight' else
     if TEdit(Sender).Color = cl3DDkShadow then Form2.Edit12.Text := '3DDKShadow'else
     if TEdit(Sender).Color = cl3DLight then Form2.Edit12.Text := '3DLight'else
     if TEdit(Sender).Color = clInfoText then Form2.Edit12.Text := 'InfoText' else
     if TEdit(Sender).Color = clInfobk then Form2.Edit12.Text := 'Infobk' else
     Form2.Edit12.Text := inttostr(integer(TEdit(Sender).Color));
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:Psylord
ID: 2783668
Thanks... but I've figured it out on my own.
0
 
LVL 1

Accepted Solution

by:
rowisoft earned 10 total points
ID: 2783675
Hy!

Good!!
And nobody gets the points???

Robert Wismet
0
 

Author Comment

by:Psylord
ID: 2783682
Since I'm a nice guy.

-Psylord
0
 
LVL 15

Expert Comment

by:simonet
ID: 2784171
What's going on here?

Robert's suggestion can be made **A LOT** faster:

1) by using CASE statements
2) by dropping all testing statements and using ColorToIdent

Alex
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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…
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…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.

831 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