Вниз
Скачать: 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 вся ветка

Скачать: CL | DM;



Память: 0.45 MB
Время: 0.014 c
1-3451
kima
2002-08-20 19:10
2002.09.02
arccot()


1-3457
Cem
2002-08-20 20:36
2002.09.02
Как сделать, чтобы компонент рисовал на своем parent.


1-3388
Cowboy
2002-08-22 11:29
2002.09.02
Определение диска.


1-3453
DeepProg
2002-08-20 15:32
2002.09.02
Сделано или нет?


1-3430
GIL
2002-08-22 05:26
2002.09.02
Только для умных!!!




   Наверх