I want to adjust the pictures valign property after the paste action, the problem is after I finished the adjusting ,the caret position is set to the pasted content beginning automatic, not at the end of the pasted content normally.How to fix this?
private
pasted:Boolean;
procedure TfrmRvfEditorMain.SRichViewEdit1Paste(Sender: TCustomRichViewEdit; var DoDefault: Boolean);
begin
pasted := True;
DoDefault:=True;
end;
procedure TfrmRvfEditorMain.SRichViewEdit1Change(Sender: TObject);
var
rve: TRichViewEdit;
begin
rve := TSRichViewEdit(Sender).RichViewEdit;
if pasted then
begin
//adjust the valign
RVAlignImages(rve);
pasted := False;
end;
end;
procedure TfrmRvfEditorMain.RVAlignImages(rve: TRichViewEdit; iAlign: TRVVAlign = rvvaAbsMiddle);
var
i: Integer;
StyleNo: Integer;
begin
if rve = nil then
exit;
for i := 0 to rve.ItemCount - 1 do
begin
StyleNo := rve.GetItemStyle(i);
if StyleNo = rvsPicture then
begin
rve.SetItemVAlign(i, iAlign);
end;
end;
rve.Format;
end;