型態轉換.... |
尚未結案
|
confidante
一般會員 發表:5 回覆:5 積分:2 註冊:2002-11-04 發送簡訊給我 |
|
RaynorPao
版主 發表:139 回覆:3622 積分:7025 註冊:2002-08-12 發送簡訊給我 |
|
Rain
資深會員 發表:31 回覆:236 積分:268 註冊:2003-02-17 發送簡訊給我 |
//把字体转化为字符串
//输出的格式:
// 宋体,134,9,[Bold|Italic],[clAqua]
function FontToString(Font : TFont ) : string;
var
sStyle : string;
begin
with Font do
begin
// convert font style to string
sStyle := ''; if( fsBold in Style )then
sStyle := sStyle csfsBold; if( fsItalic in Style )then
sStyle := sStyle csfsItalic; if( fsUnderline in Style )then
sStyle := sStyle csfsUnderline; if( fsStrikeout in Style )then
sStyle := sStyle csfsStrikeout; if( ( Length( sStyle ) > 0 ) and ( '|' = sStyle[ 1 ] ) )then //去除第一个 ‘|’
begin
sStyle := Copy( sStyle, 2,Length( sStyle ) - 1 );
end; Result := Format('%s,%d,%d,[%s],[%s]',
[ Name, //字体的名称
CharSet, //字符集
Size, //字体的大小
sStyle, //字体的属性
ColorToString( Color ) ] //字体的颜色
);
end;
end; //把字符串转换为字体的相关属性!
//sFont参数的格式: 宋体,134,9,[Bold],[clRed]
procedure StringToFont(sFont : string; Font : TFont );
var
p : integer;
sStyle : string;
begin
with Font do
begin
// get font name
p := Pos( ',', sFont );
Name := Copy( sFont, 1, p-1 );
Delete( sFont, 1, p ); // get font charset
p := Pos( ',', sFont );
Charset :=StrToInt( Copy( sFont, 1, p-1 ) );
Delete( sFont, 1, p ); // get font size
p := Pos( ',', sFont );
Size :=StrToInt( Copy( sFont, 1, p-1 ) );
Delete( sFont, 1, p ); // get font style
p := Pos( ',', sFont );
sStyle := '|' Copy( sFont, 2, p-3 );
Delete( sFont, 1, p ); // get font color
Color :=StringToColor(Copy( sFont, 2,Length( sFont ) - 2 ) ); // convert str font style to font style
Style := []; if( Pos( csfsBold,sStyle ) > 0 )then
Style := Style [ fsBold ]; if( Pos( csfsItalic,sStyle ) > 0 )then
Style := Style [ fsItalic ]; if( Pos( csfsUnderline,sStyle ) > 0 )then
Style := Style [ fsUnderline ]; if( Pos( csfsStrikeout,sStyle ) > 0 )then
Style := Style [ fsStrikeout ];
end;
end;
|
Rain
資深會員 發表:31 回覆:236 積分:268 註冊:2003-02-17 發送簡訊給我 |
//sFont参数的格式: 宋体,134,9,[Bold],[clRed]
procedure StringToFont(sFont : string; Font : TFont );
var
p : integer;
sStyle : string;
begin
with Font do
begin
// get font name
p := Pos( ',', sFont );
Name := Copy( sFont, 1, p-1 );
Delete( sFont, 1, p ); // get font charset
p := Pos( ',', sFont );
Charset :=StrToInt( Copy( sFont, 1, p-1 ) );
Delete( sFont, 1, p ); // get font size
p := Pos( ',', sFont );
Size :=StrToInt( Copy( sFont, 1, p-1 ) );
Delete( sFont, 1, p ); // get font style
p := Pos( ',', sFont );
sStyle := '|' Copy( sFont, 2, p-3 );
Delete( sFont, 1, p ); // get font color
Color :=StringToColor(Copy( sFont, 2,Length( sFont ) - 2 ) ); // convert str font style to font style
Style := []; if( Pos( csfsBold,sStyle ) > 0 )then
Style := Style [ fsBold ]; if( Pos( csfsItalic,sStyle ) > 0 )then
Style := Style [ fsItalic ]; if( Pos( csfsUnderline,sStyle ) > 0 )then
Style := Style [ fsUnderline ]; if( Pos( csfsStrikeout,sStyle ) > 0 )then
Style := Style [ fsStrikeout ];
end;
end;
|
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |