全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1357
推到 Plurk!
推到 Facebook!

型態轉換....

尚未結案
confidante
一般會員


發表:5
回覆:5
積分:2
註冊:2002-11-04

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-02-17 16:02:20 IP:61.216.xxx.xxx 未訂閱
^^ 請問一下...關於型態轉換的問題... Str : String; Fnottp : TFont; 請問各位大大...要如何讓 Str := Fnottp ; 成立呢? 有 FontToStr 這種的指令嗎??
RaynorPao
版主


發表:139
回覆:3622
積分:7025
註冊:2002-08-12

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-02-17 16:09:12 IP:203.73.xxx.xxx 未訂閱
引言: ^^ 請問一下...關於型態轉換的問題... Str : String; Fnottp : TFont; 請問各位大大...要如何讓 Str := Fnottp ; 成立呢? 有 FontToStr 這種的指令嗎??
confidante 你好: 你要的是這樣嗎??
------
-- 若您已經得到滿意的答覆,請適時結案!! --
-- 欲知前世因,今生受者是;欲知來世果,今生做者是 --
-- 一切有為法,如夢幻泡影,如露亦如電,應作如是觀 --
Rain
資深會員


發表:31
回覆:236
積分:268
註冊:2003-02-17

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-02-17 21:07:05 IP:218.5.xxx.xxx 未訂閱
//把字体转化为字符串 //输出的格式: // 宋体,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

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-02-17 21:09:35 IP:218.5.xxx.xxx 未訂閱
//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;
系統時間:2024-03-29 3:59:31
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!