J jhlz1968 Unregistered / Unconfirmed GUEST, unregistred user! 2009-03-30 #1 RichView中有以下内容:中华人民共和国北京为人民服务怎样让 某一行 高亮显示,即让某一行的字体颜色变为红色
D djrj Unregistered / Unconfirmed GUEST, unregistred user! 2009-03-30 #2 先uses单元RichEdit,然后rocedure TForm1.Button1Click(Sender: TObject);var s: string; Format: CHARFORMAT2; k: Integer;begin FillChar(Format, SizeOf(Format), 0); s:= '中华人民共和国'; k:= Pos(s, RichEdit1.Text); if k > 0 then begin RichEdit1.SelStart:= k - 1; RichEdit1.SelLength:= Length(s); RichEdit1.SelAttributes.Color:= clBlue; Format.cbSize:= SizeOf(Format); Format.dwMask:= CFM_BACKCOLOR; Format.crBackColor:= clRed; RichEdit1.Perform(EM_SETCHARFORMAT, SCF_SELECTION, Longint(@Format)); end;end;
先uses单元RichEdit,然后rocedure TForm1.Button1Click(Sender: TObject);var s: string; Format: CHARFORMAT2; k: Integer;begin FillChar(Format, SizeOf(Format), 0); s:= '中华人民共和国'; k:= Pos(s, RichEdit1.Text); if k > 0 then begin RichEdit1.SelStart:= k - 1; RichEdit1.SelLength:= Length(s); RichEdit1.SelAttributes.Color:= clBlue; Format.cbSize:= SizeOf(Format); Format.dwMask:= CFM_BACKCOLOR; Format.crBackColor:= clRed; RichEdit1.Perform(EM_SETCHARFORMAT, SCF_SELECTION, Longint(@Format)); end;end;