Вниз
Скачать: 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.01 c
3-3303
edik
2002-08-13 00:05
2002.09.02
ADO


1-3335
lenin
2002-08-21 13:51
2002.09.02
NMSMTP


4-3660
guliver
2002-06-26 06:00
2002.09.02
System Trey


7-3653
KPY
2002-06-19 17:10
2002.09.02
Связанно ли это с Hooks?


14-3628
Invega
2002-08-07 21:18
2002.09.02
А из Луганска, что на Украине есть кто?




   Наверх