When I use the rvaActions's Insert Picture menu to insert the image into a RichViewEdit, I would like to set the image size to about 100 x 100 and also allow the user to resize it.
Sergey, you gave me the following code but I don't know how to use it in the action list:-
rve.TopLevelEditor.BeginUndoGroup(rvutInsert);
rve.TopLevelEditor.SetUndoGroupMode(True);
if rve.InsertPicture(...) then begin
rve.SetCurrentItemExtraIntProperty(rvepImageHeight, 100, True);
rve.SetCurrentItemExtraIntProperty(rvepImageWidth, 100, True);
// The following line to be removed to allow user resize
rve.SetCurrentItemExtraIntProperty(rvepResizable, 0, True);
end;
rve.TopLevelEditor.SetUndoGroupMode(False);
I am self-answering this post. What I did was to create a menu button in the action list menu and in the OnClick event of the menu item, I entered the following code (with examples from the help file and Sergey) :-
var
rve : TRichViewEdit;
gr : TGraphic;
pic : TPicture;
begin
rve:=rchContent; // This is the name of the control I am using
if OpenPictureDialog1.Execute then begin
pic := TPicture.Create;
try
pic.LoadFromFile(OpenPictureDialog1.FileName);
gr := RV_CreateGraphics(TGraphicClass(pic.Graphic.ClassType));
gr.Assign(pic.Graphic);
rve.BeginUpdate;
rve.TopLevelEditor.BeginUndoGroup(rvutInsert);
rve.TopLevelEditor.SetUndoGroupMode(True);
if rve.InsertPicture('', gr, rvvaBaseline) then begin
rve.SetCurrentItemExtraIntProperty(rvepImageHeight, 200, True);
rve.SetCurrentItemExtraIntProperty(rvepImageWidth, 200, True);
end;
rve.TopLevelEditor.SetUndoGroupMode(False);
rve.EndUpdate;
finally
pic.Free;
end;
end;
end;