Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2008.06.08;
Скачать: CL | DM;

Вниз

Преобразование типов   Найти похожие ветки 

 
troyan_81   (2008-05-15 10:19) [0]

В конфигурационный файл необходимо сохранить стиль шрифта. Каким образом это можно реализовать?

ini.WriteString("PREVIEW","Font Name",form4.Panel2.Font.Style);


 
Сергей М. ©   (2008-05-15 10:30) [1]

Хм .. странно ..

Параметр в секции называется "Font Name", а записывать ты туда намерен не имя фонта, а его стиль ..

Ну да не принципиально.

А стиль в конф.файле должен быть "читабельным" ?

Я к тому, что хранить состояние множества в текстовом виде можно по-разному.
Например,

FontStyle=fsBold,fsUnderline

эквивалентно

FontStyle=5


 
Юрий Зотов ©   (2008-05-15 10:34) [2]

Стиль шрифта - это множество из 4-х значений. Его можно рассматривать, как однобайтовое целое, принимающее значения от 0 до 9.

var
 Style: TFontStyle;
 StyleValue: byte absolute Style;

========

 // Запись
 Style := Form4.Panel2.Font.Style);
 Ini.WriteInteger(... StyleValue...);  

 // Чтение
 StyleValue := Ini.ReadInteger(...);
 Form4.Panel2.Font.Style) := Style;


 
troyan_81   (2008-05-15 10:36) [3]

т.е. так можно завести массив (или мнгожество), производить проверку и хранить например, в integer или String?


 
troyan_81   (2008-05-15 10:44) [4]

Чет ничего не получается :(

Приведу весь фрагмент кода

//Сохранение настроек
procedure Save;
begin
 ini:= TIniFile.Create(extractfilepath(paramstr(0))+"setting.ini");
 Style := Form4.Panel2.Font.Style;
 ini.WriteString("SETTING","Scin",form4.Scin_Label_Form4.Caption);
 ini.WriteString("PREVIEW","Font Name",form4.Panel2.Font.Name);
 ini.WriteInteger("PREVIEW","Font Size",form4.Panel2.Font.Size);
 ini.WriteInteger("PREVIEW","Font Color",form4.Panel2.Font.Color);
 ini.WriteInteger("PREVIEW","Panel Color",form4.Panel2.Color);
 ini.WriteInteger("PREVIEW","Font Style",StyleValue);
 ini.Free;
end;

//загрузка насторек
procedure Load;
begin
 ini:= TIniFile.Create(extractfilepath(paramstr(0))+"setting.ini");
 StyleValue := Ini.ReadInteger("PREVIEW","Font Style",form4.Panel2.Font.Style);
 form4.Scin_Label_Form4.Caption:=ini.ReadString("SETTING","Scin",form4.Scin_Label _Form4.Caption);
 form4.Panel2.Font.Name:= ini.ReadString("PREVIEW","Font Name",form4.Panel2.Font.Name);
 form4.Panel2.Font.Size:= ini.ReadInteger("PREVIEW","Font Name",form4.Panel2.Font.Size);
 form4.Panel2.Font.color:= ini.ReadInteger("PREVIEW","Font Color",form4.Panel2.Font.Color);
 form4.Panel2.Color:= ini.ReadInteger("PREVIEW","Panel Color",form4.Panel2.Color);
 StyleValue:= ini.ReadInteger("PREVIEW","Font Style",form4.Panel2.Font.style):=style;
 ini.Free;
end;



 
Ega23 ©   (2008-05-15 10:44) [5]


function SetFontStyle(const Value: integer): TFontStyles;
begin
Result:=[];
if ((Value shr 0) and 1)=1 then Result:=Result+[fsBold];
if ((Value shr 1) and 1)=1 then Result:=Result+[fsItalic];
if ((Value shr 2) and 1)=1 then Result:=Result+[fsUnderline];
if ((Value shr 3) and 1)=1 then Result:=Result+[fsStrikeout];
end;

//******************************************************************************** ***

function GetFontStyle(const Value: TFontStyles): Integer;
begin
Result:=0;
if (fsBold in Value) then Result:=Result or 1;
if (fsItalic in Value) then Result:=Result or 2;
if (fsUnderline in Value) then Result:=Result or 4;
if (fsStrikeout in Value) then Result:=Result or 8;
end;


 
Юрий Зотов ©   (2008-05-15 10:46) [6]

Сорри, нужна маленькая поправка:
Style: TFontStyles;


 
Юрий Зотов ©   (2008-05-15 10:48) [7]

> troyan_81

И небольшая рекомендация - если смените ник, к Вам будут относиться лучше.


 
Юрий Зотов ©   (2008-05-15 10:49) [8]

Блин... и еще одна поправка: от 0 до 15.


 
troyan_81   (2008-05-15 10:54) [9]

Спасибо за рекомендации, но поясню что за ник 8-)
Troyan - это кликуха (типпа Троя) а 81 - год рождения.
Ладно я над сменой ника на этом форуме - только ЗА. Извини есль чё!



Страницы: 1 вся ветка

Текущий архив: 2008.06.08;
Скачать: CL | DM;

Наверх




Память: 0.49 MB
Время: 0.025 c
2-1210945315
OLGA
2008-05-16 17:41
2008.06.08
Подскажите, пожалуйста неучу!!!!!!


15-1209383805
Gydvin
2008-04-28 15:56
2008.06.08
Непонял конструкцию


11-1189702877
rainstuff
2007-09-13 21:01
2008.06.08
Тормозит ScrollBox


15-1209024149
Anatoly Podgoretsky
2008-04-24 12:02
2008.06.08
Whete to buy DVBS in Estonia


2-1211054755
Катя
2008-05-18 00:05
2008.06.08
Нужна помощь в написании дипломного проекта