- uses RichEdit;
-
- // Met la couleur clYellow sur le fond du texte sélectionné
-
- RE_SetSelBgColor(MyRichEdit, clYellow);
-
-
- // Résupère la couleur clYellow sur le fond du texte sélectionné
-
- myColor := RE_GetSelBgColor(MyRichEdit, clYellow);
-
-
- procedure TFrmChild.RE_SetSelBgColor(RichEdit: TRichEdit; AColor: TColor);
- var
- Format: CHARFORMAT2;
- begin
- FillChar(Format, SizeOf(Format), 0);
- with Format do
- begin
- cbSize := SizeOf(Format);
- dwMask := CFM_BACKCOLOR;
- crBackColor := AColor;
- Richedit.Perform(EM_SETCHARFORMAT, SCF_SELECTION, Longint(@Format));
- end;
- end;
-
- function TFrmChild.RE_GetSelBgColor(RichEdit: TRichEdit): TColor;
- var
- Format: CHARFORMAT2;
- begin
- FillChar(Format, SizeOf(Format), 0);
- with Format do
- begin
- cbSize := SizeOf(Format);
- dwMask := CFM_BACKCOLOR;
- Richedit.Perform(EM_GETCHARFORMAT, SCF_SELECTION, Longint(@Format));
- result := Format.crBackColor;
- end;
- end;
uses RichEdit;
// Met la couleur clYellow sur le fond du texte sélectionné
RE_SetSelBgColor(MyRichEdit, clYellow);
// Résupère la couleur clYellow sur le fond du texte sélectionné
myColor := RE_GetSelBgColor(MyRichEdit, clYellow);
procedure TFrmChild.RE_SetSelBgColor(RichEdit: TRichEdit; AColor: TColor);
var
Format: CHARFORMAT2;
begin
FillChar(Format, SizeOf(Format), 0);
with Format do
begin
cbSize := SizeOf(Format);
dwMask := CFM_BACKCOLOR;
crBackColor := AColor;
Richedit.Perform(EM_SETCHARFORMAT, SCF_SELECTION, Longint(@Format));
end;
end;
function TFrmChild.RE_GetSelBgColor(RichEdit: TRichEdit): TColor;
var
Format: CHARFORMAT2;
begin
FillChar(Format, SizeOf(Format), 0);
with Format do
begin
cbSize := SizeOf(Format);
dwMask := CFM_BACKCOLOR;
Richedit.Perform(EM_GETCHARFORMAT, SCF_SELECTION, Longint(@Format));
result := Format.crBackColor;
end;
end;