首页 > 代码库 > 高亮 TRichEdit 当前行
高亮 TRichEdit 当前行
var gStart, gLength, gCol: Integer;procedure SetRichEdit(aRichEdit: TRichEdit);var fRow, fCol: Integer; fStart, fLength, tStart: Integer;begin fRow := aRichEdit.CaretPos.X; fCol := aRichEdit.CaretPos.Y; if gCol = fCol then Exit; tStart := aRichEdit.SelStart; fStart := tStart - fRow; fLength := aRichEdit.Lines[fCol].Length; aRichEdit.Lines.BeginUpdate; if fLength > 0 then begin aRichEdit.SelStart := fStart; aRichEdit.SelLength := fLength; aRichEdit.SelAttributes.Color := clRed; end; if gLength > 0 then begin aRichEdit.SelStart := gStart; aRichEdit.SelLength := gLength;// aRichEdit.SelectAll; aRichEdit.SelAttributes.Color := clBlack; end; aRichEdit.SelStart := tStart; aRichEdit.SelLength := 0; aRichEdit.Lines.EndUpdate; gStart := fStart; gLength := fLength; gCol := fCol;end;procedure TForm1.RichEdit1Click(Sender: TObject);begin SetRichEdit(TRichEdit(Sender));end;procedure TForm1.RichEdit1KeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);begin if Key in [37..40] then SetRichEdit(TRichEdit(Sender));end;
高亮 TRichEdit 当前行
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。