Solved

Font property to INI file

Posted on 1998-11-03
3
399 Views
Last Modified: 2013-12-03
I am trying to save some component's Font property ini INI file:

with Memo1 do
begin
      IniFile.WriteString('Font desc', 'Name', Font.Name);
      IniFile.WriteInteger('Font desc', 'Color', Font.Color);
      IniFile.WriteInteger('Font desc', 'Size', Font.Size);
      IniFile.WriteInteger('Font desc', 'Style', Font.Style);
end;

but it fails at compiling last line, since Style is defined as

TFontStyle = (fsBold, fsItalic, fsUnderline, fsStrikeOut);
TFontStyles = set of TFontStyle;
property Style: TFontStyles;



Same with loading from INI

with Memo1 do
begin
      Font.Name := IniFile.ReadString('Font desc', 'Name', 'Arial');
      Font.Color := IniFile.ReadInteger('Font desc', 'Color', clBlack);
      Font.Size := IniFile.ReadInteger('Font desc', 'Size', 8);
      Font.Style := IniFile.ReadInteger('Font desc', 'Style', fsBold));
end;


How to save value of set variables (like Style) in INI
(apart from creating separate boolean key for every member of set)


0
Comment
Question by:yuhoo
3 Comments
 
LVL 4

Expert Comment

by:dwwang
ID: 1345509
I think there is no direct way to do that, you have to use kind of loop to read and write from/to the INI file, using "separate boolean key for every member of set" you metioned.
0
 
LVL 5

Expert Comment

by:scrapdog
ID: 1345510
You posted this question twice.  See the other one!!


A set is stored in a byte, so you can typecast it to a byte.

var x :longint;  

{to write}

x := Byte(Font.Style);
IniFile.WriteInteger('Font desc', 'Style', x);

{to read}
 
x := IniFile.ReadInteger('Font desc', 'Style', 0));
Font.Style := TFontStyles(Byte(x));

0
 

Accepted Solution

by:
v_pasupuleti earned 50 total points
ID: 1345511
Declare
var
FontStyles as TFontStyle

and assign the value as a string from the Ini file
like FontStyles := Readstring....


0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
drawing animated level bar based on numbers 3 103
Multiple image collision 13 80
can't find the executable in Simulator 1 100
JAudiorecorder record freezing the app 29 74
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

808 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