Solved

Saving/Loading TColor - Ini's and Strings.

Posted on 2000-05-05
7
255 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
[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
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

705 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