uses <br> RichEdit; <br><br>procedure RE_SetSelBgColor(RichEdit: TRichEdit; AColor: TColor); <br>var <br> Format: CHARFORMAT2; <br>begin <br> FillChar(Format, SizeOf(Format), 0); <br> with Format do <br> begin <br> cbSize := SizeOf(Format); <br> dwMask := CFM_BACKCOLOR; <br> crBackColor := AColor; <br> Richedit.Perform(EM_SETCHARFORMAT, SCF_SELECTION, Longint(@Format)); <br> end; <br>end; <br><br>// Example: Set clYellow background color for the selected text. <br>procedure TForm1.Button1Click(Sender: TObject); <br>begin <br> RE_SetSelBgColor(RichEdit1, clYellow); <br>end; <br>需要Richedit2.0的支持<br>这个你看一下有没有帮助吧