Page 1 of 1

Save rtf with different ext

Posted: Fri Oct 11, 2019 1:03 am
by adamrich
Hi,
I have a need to save and open as rtf only file with different file extension, I'm using richviewaction
Any idea on how do that, or remove all types except rtf with different file extension .

I tried custom filter , saved ok, but I can't open it because doesn't know the format to open with.

Thanks

Re: Save rtf with different ext

Posted: Fri Oct 11, 2019 10:38 am
by Sergey Tkachenko
RichViewActions do not allow changing a file extension and a filter string for RTF (only for RVF and XML).
So using a custom format is the only option.

Property settings:
rvActionOpen1.Filter = [ffiCustom]
rvActionOpen1.CustomFilter = 'My Files|*.my'

rvActionSaveAs1.Filter = [ffeCustom]
rvActionSaveAs1.CustomFilter = 'My Files|*.my'

rvActionSave1.LostFormatWarning = []

RVAControlPanel1.DefaultExt = 'my'
RVAControlPanel1.DefaultFileFormat = ffeCustom
RVAControlPanel1.DefaultFileName = 'Untitled.my'

The code in RVAControlPanel1.OnCustomFileOperation event:

Code: Select all

procedure TForm3.RVAControlPanel1CustomFileOperation(Sender: TrvAction;
  Edit: TCustomRichViewEdit; const FileName: TRVUnicodeString;
  Operation: TRVAFileOperation; var SaveFormat: TrvFileSaveFilter;
  var CustomFilterIndex: Integer; var Success: Boolean);
begin
   case Operation of
    rvafoOpen:
      // This example assumes that there is only one custom open format,
      // so it does not check CustomFilterIndex (it must be 1)
      Success := Edit.LoadRTF(FileName);
    rvafoSave:
      // This example assumes that there is only one custom save format,
      // so it does not check CustomFilterIndex (it must be 1)
      Success := Edit.SaveRTF(FileName, False);
   end;
end;

Re: Save rtf with different ext

Posted: Fri Oct 11, 2019 1:47 pm
by adamrich
As always, you are the best, thank you so much that worked the way I needed 
Thanks again for your superb support and tools