RichEdit 轉不到 Font |
尚未結案
|
Diviner
初階會員 發表:36 回覆:112 積分:34 註冊:2002-03-13 發送簡訊給我 |
|
jest0024
高階會員 發表:11 回覆:310 積分:224 註冊:2002-11-24 發送簡訊給我 |
|
Diviner
初階會員 發表:36 回覆:112 積分:34 註冊:2002-03-13 發送簡訊給我 |
引言:早就參考過了。 我遇到的問題: 1. 即使我在 Design Time 設定好 Font Name(字型), 並且在 Lines 鍵入文字, 已經即時看到想要的結果, 但一執行程式, 字型又會再還原為 Times, 無論是文字的顏色、大小、粗幼等一律沒問題, 就只有字型會還原。 2. 執行時期設定它, 一樣無效。看這段程式碼:引言: 無論我在 IDE 中設定 RichEdit 的 Font Name 或 RunTime 設定它, 其字型都毫無改變(好像是 Times 字型, 總之是 Default 那種就是了), 但 Font Size 則能改到, 是甚麼原因呢? 另外, 若我想局部改變某些字, 但 SelAttribute 並無 Font 屬性, 又該如何操作呢? 謝謝。 -- 小卜子請參考Delphi Deom的Richedit範例!! 學而時習之不亦樂乎! with RichEdit1 do begin SelAttributes.Name := Font.Name; // (或直接用 MS Sans Serif) if Error then begin SelAttributes.Color := clRed; SelAttributes.Style := [fsBold]; end else begin SelAttributes.Color := clBlack; SelAttributes.Style := []; end; SelText := Msg; end;我已試過把 Font.CharSet 作各種嘗試, 無助。 -- 小卜子
------
-- 小卜子 |
jest0024
高階會員 發表:11 回覆:310 積分:224 註冊:2002-11-24 發送簡訊給我 |
引言:引言:早就參考過了。 我遇到的問題: 1. 即使我在 Design Time 設定好 Font Name(字型), 並且在 Lines 鍵入文字, 已經即時看到想要的結果, 但一執行程式, 字型又會再還原為 Times, 無論是文字的顏色、大小、粗幼等一律沒問題, 就只有字型會還原。 2. 執行時期設定它, 一樣無效。看這段程式碼:引言: 無論我在 IDE 中設定 RichEdit 的 Font Name 或 RunTime 設定它, 其字型都毫無改變(好像是 Times 字型, 總之是 Default 那種就是了), 但 Font Size 則能改到, 是甚麼原因呢? 另外, 若我想局部改變某些字, 但 SelAttribute 並無 Font 屬性, 又該如何操作呢? 謝謝。 -- 小卜子請參考Delphi Deom的Richedit範例!! 學而時習之不亦樂乎!with RichEdit1 do begin SelAttributes.Name := Font.Name; // (或直接用 MS Sans Serif) if Error then begin SelAttributes.Color := clRed; SelAttributes.Style := [fsBold]; end else begin SelAttributes.Color := clBlack; SelAttributes.Style := []; end; SelText := Msg; end;我已試過把 Font.CharSet 作各種嘗試, 無助。 -- 小卜子 1.在Create事件將RichEdit字型還原 procedure TForm1.FormCreate;... begin RichEdit.SelectAll; RichEdit.SelAttributes.Assign(RichEdit.Font); RichEdit.SelStart:=0; end; 2. if FontDialog.Execute then RichEdit.SelAttributes.Assign(FontDialog.Font);學而時習之不亦樂乎! |
terrychen
尊榮會員 發表:90 回覆:794 積分:501 註冊:2003-05-01 發送簡訊給我 |
引言: 無論我在 IDE 中設定 RichEdit 的 Font Name 或 RunTime 設定它, 其字型都毫無改變(好像是 Times 字型, 總之是 Default 那種就是了), 但 Font Size 則能改到, 是甚麼原因呢? 另外, 若我想局部改變某些字, 但 SelAttribute 並無 Font 屬性, 又該如何操作呢? 謝謝。 -- 小卜子您好: 你字集有設定為Chinese_Big5ㄇ? 局部改變某些字RichEdit1.SelAttributes.Name ~~應無所住而生其心~~ |
Diviner
初階會員 發表:36 回覆:112 積分:34 註冊:2002-03-13 發送簡訊給我 |
引言:局部修改文字確是可以, 但我目前使用 RichEdit 並不作為 Text Editor 用, 而是用之寫 Log 文件, 希望一加上去的文字就有某種字型顯示。其實, 我亦只要一種字型而已, 但都作不到。 -- 小卜子with RichEdit1 do begin SelAttributes.Name := Font.Name; // (或直接用 MS Sans Serif) if Error then begin SelAttributes.Color := clRed; SelAttributes.Style := [fsBold]; end else begin SelAttributes.Color := clBlack; SelAttributes.Style := []; end; SelText := Msg; end;我已試過把 Font.CharSet 作各種嘗試, 無助。 -- 小卜子1.在Create事件將RichEdit字型還原 procedure TForm1.FormCreate;... begin RichEdit.SelectAll; RichEdit.SelAttributes.Assign(RichEdit.Font); RichEdit.SelStart:=0; end; 2. if FontDialog.Execute then RichEdit.SelAttributes.Assign(FontDialog.Font);學而時習之不亦樂乎!
------
-- 小卜子 |
Diviner
初階會員 發表:36 回覆:112 積分:34 註冊:2002-03-13 發送簡訊給我 |
|
Diviner
初階會員 發表:36 回覆:112 積分:34 註冊:2002-03-13 發送簡訊給我 |
引言: 您好: 你字集有設定為Chinese_Big5ㄇ? 局部改變某些字RichEdit1.SelAttributes.Name ~~應無所住而生其心~~你說得對!!! 是字集於 RunTime 時給還原了, 怪不得無論我在 RunTime/Dev.Time 更改 Font Name 都沒用, 所以我要在 RunTime 再次給予 CharSet 屬性值才行。 是以程式碼修正如下: with RichEdit1 do begin SelAttributes.Name := 'MS Sans Serif'; SelAttributes.Size := 10; SelAttributes.Charset := ANSI_CHARSET; if Error then begin SelAttributes.Color := clRed; SelAttributes.Style := [fsBold]; end else begin SelAttributes.Color := clBlack; SelAttributes.Style := []; end; SelText := Msg #13#10; end;-- 小卜子
------
-- 小卜子 |
Diviner
初階會員 發表:36 回覆:112 積分:34 註冊:2002-03-13 發送簡訊給我 |
|
Diviner
初階會員 發表:36 回覆:112 積分:34 註冊:2002-03-13 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |