1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| procedure Surligne(const RE: TRichEdit; const Color: TColor);
var
Format : CHARFORMAT2;
begin
FillChar(Format, SizeOf(CHARFORMAT2), 0);
Format.cbSize := SizeOf(CHARFORMAT2);
SendMessage(RE.Handle, EM_GETCHARFORMAT, WPARAM(True), LPARAM(@Format));
Format.dwMask := CFM_BACKCOLOR;
Format.crBackColor := ColorToRGB(Color);
Format.dwEffects := 0; // CFE_AUTOBACKCOLOR
SendMessage(RE.Handle, EM_SETCHARFORMAT, SCF_SELECTION, LPARAM(@Format))
end;
procedure SurligneUneLigne(const RE: TRichEdit; const Color: TColor;NumeroDeLigne:integer);
begin
RE.SelStart:=RE.Perform(EM_LINEINDEX, NumeroDeLigne, 0);
RE.SelLength:=RE.Perform(EM_LINELENGTH, RE.SelStart, 0);
Surligne(RE,Color);
end; |
Partager