RVAInsertPicture : Catching image filename?

General TRichView support forum. Please post your questions here
Post Reply
vega
Posts: 50
Joined: Fri Oct 26, 2007 6:29 am

RVAInsertPicture : Catching image filename?

Post by vega »

When an image is added to RVE through RVAInsertPicture, I need to copy this image file to another folder and replace the original location with the new location.

The question is : How do I collect the image path and name immediately after the RVA ImageOpen dialog closes?

Thanks, Dan
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Unfortunately, there is no event for this.
But you can use OnExecute event of this action:
This code displays file name of the inserted picture, if rvActionInsertPicture1.StoreFileName=True (not a default value!)

Code: Select all

procedure TrvActionsResource.rvActionInsertPicture1Execute(
  Sender: TObject);
var Item: TCustomRVItemInfo;
    FileName: String;
begin
  Item := RichViewEdit1.GetCurrentItem;
  rvActionInsertPicture1.OnExecute := nil;
  rvActionInsertPicture1.Execute;
  rvActionInsertPicture1.OnExecute := rvActionInsertPicture1Execute;
  if Item<>RichViewEdit1.GetCurrentItem then begin
    RichViewEdit1.GetCurrentItemExtraStrProperty(rvespImageFileName, FileName);
    Application.MessageBox(PChar(FileName), 'File Name', 0);
  end;
end;
vega
Posts: 50
Joined: Fri Oct 26, 2007 6:29 am

Post by vega »

Sergey Tkachenko wrote:

Code: Select all

procedure TrvActionsResource.rvActionInsertPicture1Execute(
  Sender: TObject);
var Item: TCustomRVItemInfo;
    FileName: String;
begin
  Item := RichViewEdit1.GetCurrentItem;
  rvActionInsertPicture1.OnExecute := nil;
  rvActionInsertPicture1.Execute;
  rvActionInsertPicture1.OnExecute := rvActionInsertPicture1Execute;
  if Item<>RichViewEdit1.GetCurrentItem then begin
    RichViewEdit1.GetCurrentItemExtraStrProperty(rvespImageFileName, FileName);
    Application.MessageBox(PChar(FileName), 'File Name', 0);
  end;
end;
Thanks Sergey, it works fine but the problem is that this procedure is not called when user right-clicks the RVE and changes the picture through the 'Object Properties' popup menu option. Any way around this?

Accessorily, it would be nice if the 'Object Properties' dialog had an option to put a border around the image.

Thanks, Dan
Post Reply