線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:2928
推到 Plurk!
推到 Facebook!

讀出TXT 的文字檔,能顯示文字是彩色的

 
banson1716
高階會員


發表:55
回覆:182
積分:167
註冊:2002-04-14

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-07-29 08:23:15 IP:218.175.xxx.xxx 未訂閱
●在 TRichEdit 讀出 "TXT" 的文字檔,能顯示文字是多種彩色的● ========================================== procedure TForm1.FormCreate(Sender: TObject); var X, Y : integer; inText : string; const Textcolor = clRed; Textcolor1 = clGreen; Textcolor2 = clPurple; begin inText := 'begin'; Y := length(Editor.Text); for X := 1 to Y do begin if(Copy(Editor.Text, X, Length(inText)) = inText)then begin Editor.SelStart := X - 1; Editor.SelLength := length(inText); Editor.SelAttributes.Color := Textcolor; end; end; //----------------------------------------------------- inText := 'end'; y := length(Editor.Text); for X := 1 to Y do begin if(Copy(Editor.Text, X, Length(inText)) = inText) then begin Editor.SelStart := X - 1; Editor.SelLength := length(inText); Editor.SelAttributes.Color := Textcolor1; end; end; //----------------------------------------------------- inText := 'procedure'; Y := length(Editor.Text); for X := 1 to Y do begin if(Copy(Editor.Text, X, Length(inText)) = inText) then begin Editor.SelStart := X - 1; Editor.SelLength := length(inText); Editor.SelAttributes.Color := Textcolor2; end; end; SendMessage(Editor.Handle, EM_SETSEL, 0, 0); SendMessage(Editor.Handle, EM_SCROLLCARET, 0, 0); end;
banson1716
高階會員


發表:55
回覆:182
積分:167
註冊:2002-04-14

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-07-31 21:47:44 IP:218.175.xxx.xxx 未訂閱
加入此段可顯示關鍵字自動為粗體及執行多緒 Editor.SelAttributes.Style := [fsBold]; ======================================== ............ TFooThread = class(TThread) protected procedure Execute; override; end; ........... procedure TFormMain.ToolButton1Click(Sender: TObject); begin TFooThread.Create(true); TFooThread.Create(False); end; procedure TFooThread.Execute; var X, Y : integer; inText : string; const Textcolor = clRed; Textcolor1 = clGreen; Textcolor2 = clPurple; begin with FormMain do begin Editor.SelAttributes.Style := [fsBold]; inText :=Edit1.text; if Edit1.text='' then Exit; Y := length(Editor.Text); for X := 1 to Y do if(Copy(Editor.Text, X, Length(inText)) = inText)then begin Editor.SelStart := X - 1; Editor.SelLength := length(inText); //Editor.SelAttributes.Style := [fsBold]; Editor.SelAttributes.Color := Textcolor; end; //----------------------------------------------------- inText := Edit2.text; if Edit2.text='' then Exit; y := length(Editor.Text); for X := 1 to Y do if(Copy(Editor.Text, X, Length(inText)) = inText) then begin Editor.SelStart := X - 1; Editor.SelLength := length(inText); //Editor.SelAttributes.Style := [fsBold]; Editor.SelAttributes.Color := Textcolor1; end; //----------------------------------------------------- inText:= Edit3.text; if Edit3.text='' then Exit; Y := length(Editor.Text); for X := 1 to Y do if(Copy(Editor.Text, X, Length(inText)) = inText) then begin Editor.SelStart := X - 1; Editor.SelLength := length(inText); //Editor.SelAttributes.Style := [fsBold]; Editor.SelAttributes.Color := Textcolor2; end; SendMessage(Editor.Handle, EM_SETSEL, 0, 0); SendMessage(Editor.Handle, EM_SCROLLCARET, 0, 0); end; end; 發表人 - banson1716 於 2003/07/31 21:53:53
系統時間:2024-05-18 22:40:14
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!