Solved

Font property to INI file

Posted on 1998-11-03
3
401 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
[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 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

Independent Software Vendors: 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

Suggested Solutions

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…
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…
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

730 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