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

Вниз

!   Найти похожие ветки 

 
LDKL   (2002-08-22 15:52) [0]

Мне надо сохранить в ini-файл значение переменных типа TColor и TFontStyles!
Птом загрузить их...
Как это можно организовать?


 
Jeer ©   (2002-08-22 16:05) [1]

А посмотреть что за типы это не судьба ?


 
Skier ©   (2002-08-22 16:12) [2]

>LDKL


procedure TForm1.Button2Click(Sender: TObject);

function FontStylesToStr(const AFontStyles : TFontStyles) :
String;
begin
Result := EmptyStr;
if fsBold in AFontStyles then Result := Result + "1"
else Result := Result + "0";
if fsItalic in AFontStyles then Result := Result + "1"
else Result := Result + "0";
if fsUnderline in AFontStyles then Result := Result + "1"
else Result := Result + "0";
if fsStrikeOut in AFontStyles then Result := Result + "1"
else Result := Result + "0";
end; //FontStylesToStr

function StrToFontStyles(const AStr : String) : TFontStyles;
const
F_BOLD = 1;
F_ITALIC = 2;
F_UNDERLINE = 3;
F_STRIKEOUT = 4;
var
ii : Integer;
begin
Result := [];
if AStr = EmptyStr then Exit;
if Length(AStr) <> 4 then Exit;
for ii := 1 to Length(AStr) do begin
case ii of
F_BOLD : begin
if AStr[ii] = "1" then Result := Result + [fsBold];
end; //F_BOLD
F_ITALIC : begin
if AStr[ii] = "1" then Result := Result + [fsItalic];
end; //F_ITALIC
F_UNDERLINE : begin
if AStr[ii] = "1" then Result := Result + [fsUnderline];
end; //F_UNDERLINE
F_STRIKEOUT : begin
if AStr[ii] = "1" then Result := Result + [fsStrikeOut];
end; //F_STRIKEOUT
end; //case
end; //for
end; //StrToFontStyles

var
AStr : String;
AFontStyles : TFontStyles;
begin
AStr := FontStylesToStr(Font.Style);
AFontStyles := StrToFontStyles(AStr);
//при записи и чтении TFontStyles в/из ini-файл(а)
//обращаешься с TFontStyles как со строкой

//при записи и чтении TColor в/из ini-файл(а)
//обращаешься с TColor как с Integer
//т.е. Integer(AColor) и TColor(Integer)
end;


 
PVOzerski ©   (2002-08-22 16:12) [3]

tColor - это обычный целый тип, так что с ним всё просто.
tFontStyles - это тип-множество, штука сугубо паскальная и в WinAPI не предусмотренная. В ini-файл загоняемая, но только разными извратными способами. Простейший вариант - в виде строки: через запятую все входящие элементы как целые числа (обычным typecast"ом из tFontStyle в longint).


 
LDKL   (2002-08-22 17:07) [4]

Спасибо, буду знать...



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

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

Наверх




Память: 0.47 MB
Время: 0.011 c
14-3574
AL2002
2002-08-05 18:25
2002.09.02
А есть в И-нете летописи о конкурсах КВН?


7-3635
programmerts
2002-06-20 19:11
2002.09.02
Каким образом можно безболезненно удалить файлы, которые не удаля


1-3431
Yaro
2002-08-18 01:42
2002.09.02
Прозрачный Label на рабочем столе


14-3615
Lampo4ka
2002-08-08 10:02
2002.09.02
Где скачать DelphiX ?


1-3406
TBeginner
2002-08-22 16:28
2002.09.02
Incompatible types