Modify the filename of the Save dialog?
Modify the filename of the Save dialog?
Hello,
I use the following code to create a new document (using another file as base):
srvActionsResource.rvActionNew1.Execute;
MainForm.ActiveEditor.RichViewEdit.LoadRVF(ExtractFilePath(ParamStr(0))+'MyFiles\'+DocName);
MainForm.ActiveEditor.Format;
MainForm.SRVTabSet1.Tabs[MainForm.SRVTabSet1.TabIndex].Text := 'My business card 1';
My problem is that when I click on Save, in the Save dialog the filename is which was set in the RvaControlPanel.DefaultFileName.
Can I set the filename each time to what I need? e.g. 'My business card 1', 'My business card 2' etc.
Thank you
I use the following code to create a new document (using another file as base):
srvActionsResource.rvActionNew1.Execute;
MainForm.ActiveEditor.RichViewEdit.LoadRVF(ExtractFilePath(ParamStr(0))+'MyFiles\'+DocName);
MainForm.ActiveEditor.Format;
MainForm.SRVTabSet1.Tabs[MainForm.SRVTabSet1.TabIndex].Text := 'My business card 1';
My problem is that when I click on Save, in the Save dialog the filename is which was set in the RvaControlPanel.DefaultFileName.
Can I set the filename each time to what I need? e.g. 'My business card 1', 'My business card 2' etc.
Thank you
-
- Site Admin
- Posts: 17565
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
If you want to assign a file name to the editor, load it using rvActionOpen1.LoadFile:
Code: Select all
srvActionsResource.rvActionOpen1.LoadFile(MainForm.ActiveEditor.RichViewEdit,
ExtractFilePath(ParamStr(0))+'MyFiles\'+DocName, ffiRVF);
Hello,
It is slightly more complicated.
The customer wants the following:
1.choose a base document from the list (I populate a sub menu with the available base documents for him)
2.The program opens a New document
srvActionsResource.rvActionNew1.Execute;
MainForm.ActiveEditor.RichViewEdit.LoadRVF(ExtractFilePath(ParamStr(0))+'MyFiles\'+DocName);
It is very important for the customer that the new documents should have a name (therefore I use MainForm.SRVTabSet1.Tabs[MainForm.SRVTabSet1.TabIndex].Text := 'My business card '+sNumber; ) but they should be in memory and not in a saved file
3.At Save the program should set the filename in the Save dialog to the same as the MainForm.SRVTabSet1.Tabs[MainForm.SRVTabSet1.TabIndex].Text
Your method
is not good for him because the *real* base document will be loaded which should not be modified any time.
Thank you
It is slightly more complicated.
The customer wants the following:
1.choose a base document from the list (I populate a sub menu with the available base documents for him)
2.The program opens a New document
srvActionsResource.rvActionNew1.Execute;
MainForm.ActiveEditor.RichViewEdit.LoadRVF(ExtractFilePath(ParamStr(0))+'MyFiles\'+DocName);
It is very important for the customer that the new documents should have a name (therefore I use MainForm.SRVTabSet1.Tabs[MainForm.SRVTabSet1.TabIndex].Text := 'My business card '+sNumber; ) but they should be in memory and not in a saved file
3.At Save the program should set the filename in the Save dialog to the same as the MainForm.SRVTabSet1.Tabs[MainForm.SRVTabSet1.TabIndex].Text
Your method
Code: Select all
srvActionsResource.rvActionOpen1.LoadFile(MainForm.ActiveEditor.RichViewEdit,
ExtractFilePath(ParamStr(0))+'MyFiles\'+DocName, ffiRVF);
Thank you
-
- Site Admin
- Posts: 17565
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Try
Code: Select all
srvActionsResource.rvActionNew1.Execute;
MainForm.ActiveEditor.RichViewEdit.LoadRVF(ExtractFilePath(ParamStr(0))+'MyFiles\'+DocName);
srvActionsResource.rvActionSave1.GetDoc(MainForm.ActiveEditor.RichViewEdit).FileName := DocName;
Hello,
At runtime
gives me access violation...
Thank you
At runtime
Code: Select all
srvActionsResource.rvActionSave1.GetDoc(MainForm.ActiveEditor.RichViewEdit).FileName := DocName;
Thank you
-
- Site Admin
- Posts: 17565
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
I think it because GetDoc returns nil for MainForm.ActiveEditor.RichViewEdit.
It means no document information is associated by RichViewActions with this editor.
Is srvActionsResource.rvActionNew1.Execute called for the editor which is later available as MainForm.ActiveEditor? Probably not, otherwise it should work.
As a test, I added in the ActionTestTabs demo, in the procedure TForm3.OnNewEditor, after the linethe following code:
It works - when I call Save, the default file name is 'it works.rvf'.
(however, a new tab is still called 'Untitled.rvf', because its name is assigned TForm3.rvActionSave1DocumentFileChange, and this event is called in rvActionNew1.ExecuteTarget)
It means no document information is associated by RichViewActions with this editor.
Is srvActionsResource.rvActionNew1.Execute called for the editor which is later available as MainForm.ActiveEditor? Probably not, otherwise it should work.
As a test, I added in the ActionTestTabs demo, in the procedure TForm3.OnNewEditor, after the line
Code: Select all
srvActionsResource.rvActionNew1.ExecuteTarget(ActiveEditor.RichViewEdit);
Code: Select all
srvActionsResource.rvActionSave1.GetDoc(ActiveEditor.RichViewEdit).FileName := 'it works.rvf';
(however, a new tab is still called 'Untitled.rvf', because its name is assigned TForm3.rvActionSave1DocumentFileChange, and this event is called in rvActionNew1.ExecuteTarget)
-
- Site Admin
- Posts: 17565
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Hello,
The code you gave:
Works very well for all the tabs, except the first.
Perhaps because the first tab / editor already exists.
And If I use it like this:
MainForm.ActiveEditor.RichViewEdit.LoadRVF(ExtractFilePath(ParamStr(0))+DocName);
MainForm.ActiveEditor.Format;
srvActionsResource.rvActionSave1.GetDoc(MainForm.ActiveEditor.RichViewEdit).FileName := 'it works1.rvf';
then I get get Access violation.
Thank you
The code you gave:
Code: Select all
srvActionsResource.rvActionSave1.GetDoc(ActiveEditor.RichViewEdit).FileName := 'it works.rvf';
Perhaps because the first tab / editor already exists.
And If I use it like this:
MainForm.ActiveEditor.RichViewEdit.LoadRVF(ExtractFilePath(ParamStr(0))+DocName);
MainForm.ActiveEditor.Format;
srvActionsResource.rvActionSave1.GetDoc(MainForm.ActiveEditor.RichViewEdit).FileName := 'it works1.rvf';
then I get get Access violation.
Thank you
-
- Site Admin
- Posts: 17565
- Joined: Sat Aug 27, 2005 10:28 am
- Contact: