Save As custom dialog  SOLVED

PDF-XChange Editor SDK for Developers

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Post Reply
docu-track99
User
Posts: 518
Joined: Thu Dec 06, 2007 8:13 pm

Save As custom dialog

Post by docu-track99 »

Hello folks,

I would like to know if you could please share your default "Save As" dialog code.

I had to add a customer handler to the SaveAs cmd in order to check the file path and prompt the user if the current document contains a certain string in that file path, kind of as a warning.

In doing so, all I get is a stripped down version of the save dialog and I have to set all the settings again and catch certain cases, etc. For example, I'd like it to prompt me when I go to save a document with a name that would overwrite an existing document, like it's supposed to. So if you had your default Save As code to share that would save me loads of trouble.

Right now, this is what I have so far in my Command Handler, it's messy but I was just playing around with it and started to realize there are a few things to account for, so figured I would as you guys if you could share:

Code: Select all

        If pCmd.ID = nSaveAsID Then
            If nCode = CInt(PDFXEdit.UIX_CmdNotifyCodes.UIX_CmdNotify_Exec) Then
                Dim sad As New SaveFileDialog()
                If frmMain.pdfCtrl.Inst.ActiveDoc IsNot Nothing Then
                    Dim CurrentDoc As IPXV_Document = frmMain.pdfCtrl.Inst.ActiveDoc
                    Dim sPath As String = CurrentDoc.CoreDoc.SrcInfo.ActualFileName
                    If sPath.ToLower.Contains("stuff") Then
                        frmMain.pdfCtrl.Inst.ShowMsgBox("stuff","stuff","stuff")
                    End If
                End If
                sad.Filter = "PDF Files (*.pdf)|*.pdf"
                sad.FilterIndex = 1
                sad.DefaultExt = "pdf"
                sad.AddExtension = True
                sad.FileName = frmMain.pdfCtrl.Inst.ActiveDoc.CoreDoc.SrcInfo.DispFileName
                If sad.ShowDialog() = DialogResult.OK Then
                    frmMain.pdfCtrl.Inst.ActiveDoc.Save()
                End If
            End If
        End If
Thanks!
Doc.It Development
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Save As custom dialog

Post by Sasha - Tracker Dev Team »

Hello docu-track99,

That can be done much easier by using the e.document.performSave event that would be launched when the "Save" button is clicked in the save dialog:
The code would look like this (in our FullDemo project):

Code: Select all

if (e.nEventID == nIDS[(int)IDS.e_document_performSave])
{
	//Do your stuff
	//...
	//If the document should not be saved then we break
	{
		//...
		e.pEvent.Result = 0; //Also we can send the E_FAIL (0 means S_OK) or some other error message so that it would be displayed in the error message box

	}
}
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
docu-track99
User
Posts: 518
Joined: Thu Dec 06, 2007 8:13 pm

Re: Save As custom dialog

Post by docu-track99 »

That's great, thanks for the help Alex.
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17906
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Save As custom dialog

Post by Tracker Supp-Stefan »

:)
Post Reply