Главная страница
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.022 c
6-3545
Lina
2002-06-24 15:42
2002.09.02
Может кто-нибудь работал с функцией NetShareAdd ?


1-3516
TBeginner
2002-08-21 14:20
2002.09.02
Class


3-3307
Brute
2002-08-13 13:57
2002.09.02
Отсутствие драйвера INTERBASE при создании алиаса


1-3400
nikolo
2002-08-21 11:05
2002.09.02
TSession в DLL


1-3361
Елена
2002-08-22 08:09
2002.09.02
OnKeyDown формы