trichview.support
Re: text file |
Author |
Message |
Yernar |
Posted: 12/10/2002 23:42:07 Thank you, I've received your mail. Maybe that's what you need (of course, it's not perfect, but I hope it will be enough in your case): const MAKEBOLD = 1; procedure TForm1.MakeItBold(RVData: TCustomRVData); var i, r, c: Integer; table: TRVTableItemInfo; function StrIPos(const s1, s2: string; pos, max: Integer): Integer; var s, l1, l2, j: Integer; begin Result := -1; l1 := Length(s1); l2 := Length(s2); if max <= 0 then max := l2; if pos < 0 then pos := 0; if (l1 <= 0) or (pos > max) then Exit; for s := pos to (max - l1) do begin for j := 1 to l2 do begin if (s1[j] <> s2[s + j]) then BREAK; if (j = l1) then begin Result := s; Exit; end; end; end; end; procedure ProcessToBold(ProcessStr: string); var BPos, BPos2: Integer; BoldStr: string; begin BPos := StrIPos('\B\', ProcessStr, 1, Length(ProcessStr)); if BPos > 0 then begin BPos2 := StrIPos('\B\', ProcessStr, BPos + 1, Length(ProcessStr)); if BPos2 > 0 then begin BoldStr := Copy(ProcessStr, BPos + 4, BPos2 - BPos - 3); RichViewEdit1.SetSelectionBounds(0, 1, 0, 1); while RichViewEdit1.SearchText(BoldStr, [rvseoDown]) do RichViewEdit1.ApplyStyleConversion(MAKEBOLD); RichViewEdit1.Deselect; end; end; end; begin for i := 0 to RVData.Items.Count - 1 do if RVData.GetItemStyle(i) >= 0 then ProcessToBold(RVData.Items[i]); end; procedure TForm1.RichViewEdit1StyleConversion(Sender: TCustomRichViewEdit; StyleNo, UserData: Integer; AppliedToText: Boolean; var NewStyleNo: Integer); var FontInfo: TFontInfo; begin FontInfo := TFontInfo.Create(nil); try FontInfo.Assign(RVStyle2.TextStyles[StyleNo]); case UserData of MAKEBOLD: FontInfo.Style := FontInfo.Style + [fsBold] end; NewStyleNo := RVStyle2.TextStyles.FindSuchStyle(StyleNo, FontInfo, RVAllFontInfoProperties); if NewStyleNo = -1 then begin RVStyle2.TextStyles.Add; NewStyleNo := RVStyle2.TextStyles.Count - 1; RVStyle2.TextStyles[NewStyleNo].Assign(FontInfo); RVStyle2.TextStyles[NewStyleNo].Standard := False; end; finally FontInfo.Free; end; end; >"dca" <jozef.duhayon@skynet.be> wrote: >>hi, >> >>i hope you can help me with the following question >> >>question: >>I'm reading a textfile in and it has the following characters in between... >>if something is between >>/Bthis must be bold/B >> >>(between 2x /B) >>How can I read this textfile in my richtedit so that he will place the text >>between 2X /B in bold in my tricheditview >> >>kind regards >>dominick |
Powered by ABC Amber Outlook Express Converter