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

RichEdit 轉不到 Font

尚未結案
Diviner
初階會員


發表:36
回覆:112
積分:34
註冊:2002-03-13

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-05-21 12:35:52 IP:218.103.xxx.xxx 未訂閱
無論我在 IDE 中設定 RichEdit 的 Font Name 或 RunTime 設定它, 其字型都毫無改變(好像是 Times 字型, 總之是 Default 那種就是了), 但 Font Size 則能改到, 是甚麼原因呢? 另外, 若我想局部改變某些字, 但 SelAttribute 並無 Font 屬性, 又該如何操作呢? 謝謝。 -- 小卜子
------
--
小卜子
jest0024
高階會員


發表:11
回覆:310
積分:224
註冊:2002-11-24

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-05-21 12:54:43 IP:203.67.xxx.xxx 未訂閱
引言: 無論我在 IDE 中設定 RichEdit 的 Font Name 或 RunTime 設定它, 其字型都毫無改變(好像是 Times 字型, 總之是 Default 那種就是了), 但 Font Size 則能改到, 是甚麼原因呢? 另外, 若我想局部改變某些字, 但 SelAttribute 並無 Font 屬性, 又該如何操作呢? 謝謝。 -- 小卜子
請參考Delphi Deom的Richedit範例!! 學而時習之不亦樂乎!
Diviner
初階會員


發表:36
回覆:112
積分:34
註冊:2002-03-13

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-05-24 11:09:42 IP:218.103.xxx.xxx 未訂閱
引言:
引言: 無論我在 IDE 中設定 RichEdit 的 Font Name 或 RunTime 設定它, 其字型都毫無改變(好像是 Times 字型, 總之是 Default 那種就是了), 但 Font Size 則能改到, 是甚麼原因呢? 另外, 若我想局部改變某些字, 但 SelAttribute 並無 Font 屬性, 又該如何操作呢? 謝謝。 -- 小卜子
請參考Delphi Deom的Richedit範例!! 學而時習之不亦樂乎!
早就參考過了。 我遇到的問題: 1. 即使我在 Design Time 設定好 Font Name(字型), 並且在 Lines 鍵入文字, 已經即時看到想要的結果, 但一執行程式, 字型又會再還原為 Times, 無論是文字的顏色、大小、粗幼等一律沒問題, 就只有字型會還原。 2. 執行時期設定它, 一樣無效。看這段程式碼:
  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

發送簡訊給我
#4 引用回覆 回覆 發表時間:2004-05-24 19:18:22 IP:203.67.xxx.xxx 未訂閱
引言:
引言:
引言: 無論我在 IDE 中設定 RichEdit 的 Font Name 或 RunTime 設定它, 其字型都毫無改變(好像是 Times 字型, 總之是 Default 那種就是了), 但 Font Size 則能改到, 是甚麼原因呢? 另外, 若我想局部改變某些字, 但 SelAttribute 並無 Font 屬性, 又該如何操作呢? 謝謝。 -- 小卜子
請參考Delphi Deom的Richedit範例!! 學而時習之不亦樂乎!
早就參考過了。 我遇到的問題: 1. 即使我在 Design Time 設定好 Font Name(字型), 並且在 Lines 鍵入文字, 已經即時看到想要的結果, 但一執行程式, 字型又會再還原為 Times, 無論是文字的顏色、大小、粗幼等一律沒問題, 就只有字型會還原。 2. 執行時期設定它, 一樣無效。看這段程式碼:
  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

發送簡訊給我
#5 引用回覆 回覆 發表時間:2004-05-24 19:42:31 IP:61.221.xxx.xxx 未訂閱
引言: 無論我在 IDE 中設定 RichEdit 的 Font Name 或 RunTime 設定它, 其字型都毫無改變(好像是 Times 字型, 總之是 Default 那種就是了), 但 Font Size 則能改到, 是甚麼原因呢? 另外, 若我想局部改變某些字, 但 SelAttribute 並無 Font 屬性, 又該如何操作呢? 謝謝。 -- 小卜子
您好: 你字集有設定為Chinese_Big5ㄇ? 局部改變某些字RichEdit1.SelAttributes.Name ~~應無所住而生其心~~
Diviner
初階會員


發表:36
回覆:112
積分:34
註冊:2002-03-13

發送簡訊給我
#6 引用回覆 回覆 發表時間:2004-05-25 11:46:26 IP:218.103.xxx.xxx 未訂閱
引言:
  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);
學而時習之不亦樂乎!
局部修改文字確是可以, 但我目前使用 RichEdit 並不作為 Text Editor 用, 而是用之寫 Log 文件, 希望一加上去的文字就有某種字型顯示。其實, 我亦只要一種字型而已, 但都作不到。 -- 小卜子
------
--
小卜子
Diviner
初階會員


發表:36
回覆:112
積分:34
註冊:2002-03-13

發送簡訊給我
#7 引用回覆 回覆 發表時間:2004-05-25 11:59:29 IP:218.103.xxx.xxx 未訂閱
【取消】 -- 小卜子 發表人 - diviner 於 2004/05/25 13:01:52
------
--
小卜子
Diviner
初階會員


發表:36
回覆:112
積分:34
註冊:2002-03-13

發送簡訊給我
#8 引用回覆 回覆 發表時間:2004-05-25 12:00:34 IP:218.103.xxx.xxx 未訂閱
引言: 您好: 你字集有設定為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

發送簡訊給我
#9 引用回覆 回覆 發表時間:2004-05-25 12:25:41 IP:218.103.xxx.xxx 未訂閱
【取消】 -- 小卜子 發表人 - diviner 於 2004/05/25 12:59:38
------
--
小卜子
Diviner
初階會員


發表:36
回覆:112
積分:34
註冊:2002-03-13

發送簡訊給我
#10 引用回覆 回覆 發表時間:2004-05-25 12:54:43 IP:218.103.xxx.xxx 未訂閱
【取消】 -- 小卜子 發表人 - diviner 於 2004/05/25 13:00:36
------
--
小卜子
系統時間:2024-05-17 18:07:48
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!