Hi,
This is the code Im using, as you can see it's the same as your recomendation.
procedure ReplaceAllBoldItalic(var ARichMemo: TRichMemo; const SearchText, ReplaceText: string);
var
StartPos, EndPos: Integer;
SearchOptions: TSearchOptions;
TextParams: TFontParams;
begin
SearchOptions := [soMatchCase]; // I let options blank, feel free to play with them
StartPos := 0;
while ARichMemo.Search(SearchText, StartPos, ARichMemo.GetTextLen, SearchOptions, StartPos, EndPos) do
begin
// to be quick, just check first char if it got the wanted style
// if that is to unprecise for your usage, extend this block to check all positions
if ARichMemo.GetTextAttributes(StartPos, TextParams) then
begin
if (fsItalic in TextParams.Style) or (fsBold in TextParams.Style) then
begin
ARichMemo.SelStart := StartPos;
ARichMemo.SelLength := EndPos;
ARichMemo.SelText := ReplaceText;
end;
end;
StartPos := StartPos + Length(ReplaceText);
end;
end;
this is where i call for replacing the code:
ReplaceAllBoldItalic(rmDoc, 'name', qry.fieldbyname('name').asstring);
but then all the text gets replaced with only qry.fieldbyname('name').asstring.
how can I correct this problem.
TIA
Ramiro