Save rtf with different ext

General TRichView support forum. Please post your questions here
Post Reply
adamrich
Posts: 35
Joined: Sun Feb 19, 2006 1:55 pm

Save rtf with different ext

Post 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
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Save rtf with different ext

Post 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;
adamrich
Posts: 35
Joined: Sun Feb 19, 2006 1:55 pm

Re: Save rtf with different ext

Post 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
Post Reply