Solved

Font property to INI file

Posted on 1998-11-03
3
394 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
Comment Utility
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
Comment Utility
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
Comment Utility
Declare
var
FontStyles as TFontStyle

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


0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

772 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

14 Experts available now in Live!

Get 1:1 Help Now