Главная страница
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.035 c
1-3369
c0pyc@t
2002-08-22 09:24
2002.09.02
Передача строки в ДЛЛ


3-3304
Азазелло
2002-08-13 09:00
2002.09.02
Удаленная работа с MSSQL


4-3658
ed2000
2002-06-29 20:16
2002.09.02
Отключение прорисовки формы


1-3520
Sergey V. Shadrin
2002-08-21 15:22
2002.09.02
Ошибка?


3-3264
glory_bug
2002-08-09 21:32
2002.09.02
Работа с базой без