Solved

Saving/Loading TColor - Ini's and Strings.

Posted on 2000-05-05
7
249 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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

707 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

17 Experts available now in Live!

Get 1:1 Help Now