Register / handle tab close event(s)  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
User avatar
MartinCS
User
Posts: 153
Joined: Thu Apr 07, 2011 10:01 am
Contact:

Register / handle tab close event(s)

Post by MartinCS »

Hello Tracker-Team,

I'm using version 5.5.314.0 of the PDF-XChange Editor Core API.

I would like to run specified code in the PdfCtl_OnEvent method of the AxPDFXEdit.AxPXV_Control when the user closes a document tab.

For example, I'm using the following code in order to register and handle an event when a user pastes an annotation:

Code: Select all

private int eventIdAnnotsInsterted;

...

this.eventIdAnnotsInsterted = this.pdfCtl.Inst.Str2ID("e.annots.inserted");

...

this.pdfCtl.EnableEventListening2(this.eventIdAnnotsInsterted, true);

...

private void PdfCtl_OnEvent(object sender, AxPDFXEdit._IPXV_ControlEvents_OnEventEvent e)
{
#if DEBUG
   Debug.WriteLine("pdfCtl.OnEvent: e.nEventID=={0}", e.nEventID);
#endif

   if (e.nEventID == this.eventIdActiveDocChanged)
   {
      PdfEditorEx.PdfEditorActiveDocChanged();
   }

   if (e.nEventID == this.eventIdAnnotsInsterted)
   {
      PdfEditorEx.PdfEditorAnnotsInserted(e.pEvent);
   }
}
Could you give me the complete list of eventIds I can register to using the AxPDFXEdit.AxPXV_Control, please?

The list of I eventIds I'm aware of are the following:
  • e.annots.inserted
  • e.activeDocChanged
  • e.document.modStateChanged
Thank you in advance for your help!


Martin
espens
User
Posts: 45
Joined: Wed Jan 14, 2009 7:31 am

Re: Register / handle tab close event(s)

Post by espens »

Look into one of these:

e.pagesView.closed
e.documentView.closed
e.document.closed
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3549
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada
Contact:

Re: Register / handle tab close event(s)  SOLVED

Post by Ivan - Tracker Software »

We are working on the help page with the list of all available events, but it is not yet ready.

Here is a list of available events, without their description:

// app events
e.app.initialized
e.app.beforeShutdown
e.app.prefsChanged
e.app.startLoadingPlugins
e.app.finishLoadingPlugins
e.app.licenseChanged
e.app.beforeSaveUserSettings
e.app.extResourcesChanged
e.app.newNavHistoryOpts
e.app.beforeExportSettings
e.app.afterExportSettings
e.app.beforeImportSettings
e.app.afterImportSettings
e.app.beforeResetSettings
e.app.afterResetSettings
e.app.settingsChanged
e.app.checkForUpdateRes
e.app.updateStarted

// MainFrame events
e.mainFrame.initialized
e.mainFrame.beforeClose
e.mainFrame.closed

// MainView events
e.mainView.customizeCmdBars
e.mainView.initialized
e.mainView.beforeClose
e.mainView.closed
e.mainView.activated

// History events
e.history.changed
e.history.itemAdded
e.history.itemRemoved
e.history.itemChanged

// Misc events
e.beforeOpenDoc
e.beforeShowContextMenu
e.fontRecentsChanged
e.clipboardChanged
e.annotStateModelsChanged
e.spellCheckerChanged
e.uiThemeChanged
e.uiLanguageChanged
e.beginPropDialog
e.docFindParamsChanged
e.stampsChanged
e.stampSelected
e.newStampThumbs
e.stampsToggled
e.beginModal
e.endModal
e.commentStylesChanged
e.showCommentStyles
e.cmdCustomization
e.coloredFindResultsOpt
e.coloredSearchResultsOpt
e.loupeParamsChanged
e.activeDocChanged

// Command events
e.uiCmdBeforeExecute
e.uiCmdExecuted

// Operations events
e.operBeforeExecute
e.operExecuted

// Document events
// document opening
e.document.initialized
e.document.viewingStarted

// document activation
e.document.deactivated
e.document.activated

// document closing
e.document.beforeClose
e.document.closed

// saving document
e.document.beforeSave
e.document.askForSaveDest
e.document.askForNonIncSave
e.document.performSave
e.document.savePerformed
e.document.sourceChanged
e.document.afterSave

// open document by alternate app
e.document.beforeOpenInExtApp

// run action
e.document.beforeRunAction
e.document.afterRunAction
e.document.gotoAction

// open document scripts
e.document.beforeRunOpenScripts
e.document.afterRunOpenScripts

// invalidate and redraw pages content
e.document.invalidatePages

// document print events
e.document.beforePrint
e.document.afterPrint
e.document.xfaBeforePrint
e.document.xfaAfterPrint

// document changes history
e.document.historyChanged

// pages list changes
e.document.beforeChangePagesList
e.document.afterChangePagesList

// document misc events
e.document.formHighlightChanged
e.document.pagesViewRotationChanged
e.document.pageLabelsChanged
e.document.privModeChanged
e.document.xfaLayoutChanged
e.document.fullScreenParamsChanged
e.document.fieldFocusChanged
e.document.pagesR2LOptionChanged
e.document.permissionsChanged
e.document.propsChanged

// PDF contents events
e.document.contentsChanged

// document selection
e.docSelection.redraw
e.docSelection.changed
e.docSelection.visibilityChanged
e.docSelection.beginHighlight
e.docSelection.endHighlight

// OCG events
e.OCG.changed
e.OCG.listChanged
e.OCG.visibilityChanged

// Event from Search Results
e.document.newFindResults
e.document.findResultSelected
e.searchView.newResults
e.searchView.resultSelected

// DocumentView events
e.documentView.initialized
e.documentView.prepare
e.documentView.ready
e.documentView.beforeClose
e.documentView.closed
e.documentView.activated
e.documentView.dockChanged
e.documentView.measurementChanged

// PagesView events
e.pagesView.initialized
e.pagesView.ready
e.pagesView.beforeClose
e.pagesView.closed
e.pagesView.activated
e.pagesView.beginLayoutChanging
e.pagesView.layoutChanged
e.pagesView.endLayoutChanging
e.pagesView.inputFocusGained
e.pagesView.inputFocusLost
e.pagesView.pagesVisibilityChanged
e.pagesView.currentPageChanged
e.pagesView.mouse
e.pagesView.keyboard
e.pagesView.guideLinesChanged
e.pagesView.digitizerModeChanged

// PageThumbnailsView events
e.pageThumbsView.zoomChanged

// Annotation events
e.annots.changed
e.annots.deleted
e.annots.inserted
e.annots.visibilityChanged

// Digital Signatures events
e.digitSign.added
e.digitSign.deleted
e.digitSign.verified
e.digitSigns.verified
e.digitSigns.cleared

// Form-Fields
e.formFields.changed
e.formFields.deleted
e.formFields.inserted

// Bookmarks events
e.bookmarks.changed
e.bookmarks.deleted
e.bookmarks.inserted
e.bookmarks.textSizeChanged
e.bookmarks.wrapTitles
e.bookmarks.useInheritedZoom
e.bookmarks.autoExpandBookmarks
e.bookmarks.showIcons
e.bookmarks.invalidate

// Named Dests events
e.pdfNamedDests.inserted
e.pdfNamedDests.deleted
e.pdfNamedDests.renamed
e.pdfNamedDests.set
e.pdfNamedDests.colsChanged
e.pdfNamedDests.sortChanged

// Attachments events
e.attachments.colsChanged
e.attachments.sortChanged
e.attachments.inserted
e.attachments.deleted
e.attachment.changed

// SearchProviders events
e.searchProvidersChanged
e.searchProvidersSelected

// LaunchExternalApp events
e.launchExternalAppSelected
e.launchExternalAppChanged
e.launchExternalApp
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
User avatar
MartinCS
User
Posts: 153
Joined: Thu Apr 07, 2011 10:01 am
Contact:

Re: Register / handle tab close event(s)

Post by MartinCS »

Hi Ivan,

thank you for the list! That was a great help.


Martin
User avatar
John - Tracker Supp
Site Admin
Posts: 5219
Joined: Tue Jun 29, 2004 10:34 am
Location: United Kingdom
Contact:

Re: Register / handle tab close event(s)

Post by John - Tracker Supp »

:-)
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com
docu-track99
User
Posts: 518
Joined: Thu Dec 06, 2007 8:13 pm

Re: Register / handle tab close event(s)

Post by docu-track99 »

I am editing my original post as it was irrelevant to this thread.

However, it did raise an interesting point which was I can't find any events that are raised when a second document is opened in a new tab. For example, if I want to do something to the document like change the default Zoom Mode when a it's opened in a new tab, I can't seem to do this. All the document events are fired before the tab is actually displayed. Is there an event that is fired when a new tab is initialized?

Thanks,
Doc.It Development
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Register / handle tab close event(s)

Post by Sasha - Tracker Dev Team »

Hello docu-track99,

There is an e.document.initialized event - maybe this is what you're looking for?

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: Register / handle tab close event(s)

Post by docu-track99 »

Hello Alex,

Nope, this doesn't work even for the first document you open. If you try to programmatically change the Zoom Mode for the document after the e.document.initialized event is thrown, nothing happens. However, handling e.document.viewingStarted works well to accomplish this.

My specific problem is that handling e.document.viewingStarted (and other similar events) for subsequent documents which are opening in tabs doesn't allow me to programmatically change the Zoom Mode. For some reason, the sequence of events of opening the first document vs. opening a second document in a tab is different.

The exact code I'm running to handle the event it the following:

Code: Select all

    Private Sub PdfCtrl_OnEvent(sender As Object, e As AxPDFXEdit._IPXV_ControlEvents_OnEventEvent) Handles pdfCtrl.OnEvent
        Try
            If e.nEventID = Me.eventIdReady Or e.nEventID = Me.eventIdReady Then
                Dim cmdId = pdfCtrl.Inst.Str2ID("cmd.zoom.level.fitWidth", True) 'When the document loads, force to FitWidth
                pdfCtrl.Inst.ExecUICmd2(cmdId)

            End If
        Catch ex As Exception
            modMain.mGenericError(ex)
        End Try
    End Sub
So, I'm wondering if there is an event I could catch in the sequence of events of opening a second document that would allow this code to set the Zoom Mode to FitWidth properly.

Regards,
Cameron
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Register / handle tab close event(s)

Post by Sasha - Tracker Dev Team »

Hello docu-track99,

Try this code:

Code: Select all

			if (e.nEventID == nIDS[(int)IDS.e_document_viewingStarted])
			{
				PDFXEdit.IPXV_Document Doc = (PDFXEdit.IPXV_Document)e.pFrom;
				Doc.ActiveView.PagesView.SetZoom(PDFXEdit.PXV_ZoomMode.PXV_ZoomMode_FitWidth, 100.0);
			}
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: Register / handle tab close event(s)

Post by docu-track99 »

Yes, that seems to do the trick very well, I hadn't thought of that.

Much appreciated,
Doc.It Development
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Register / handle tab close event(s)

Post by Sasha - Tracker Dev Team »

Glad that helped =)
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
docu-track99
User
Posts: 518
Joined: Thu Dec 06, 2007 8:13 pm

Re: Register / handle tab close event(s)

Post by docu-track99 »

Hello folks,

I find that when I tear away tabs, you get a new PDF editor window to work in, however the caption at the top of the new window defaults to PDF X-Change Editor instead of my custom caption.

Is there an event that fires that I can catch when a tab is "torn away" from the main window?

*Edit: It appears the issue is a little more complicated than that. I found that e.activeDocChanged is fired so I went with that event. However, it appears I can only change the caption of the main instance window, not the sub-windows. So my question should be more about how to change the caption at the top of a new window created from dragging a tab out of the main window.

Thanks,
Doc.It Development
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Register / handle tab close event(s)

Post by Sasha - Tracker Dev Team »

Hello docu-track99,

Try experimenting with these values:

Code: Select all

//This one sets general application title
pdfCtl.Inst.Settings["General.AppTitle"].v = "My App";
//This one sets the main form title style (that is 0 by default):
//0 -> "<DocName> <AppName>"
//1 -> "<AppName>"
//2 -> "<AppName> <DocName>"
pdfCtl.Inst.Settings["MainFrm.TitleStyle"].v = 1;
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: Register / handle tab close event(s)

Post by docu-track99 »

Thanks Alex. It sounded promising, but doesn't have any effect unfortunately.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Register / handle tab close event(s)

Post by Sasha - Tracker Dev Team »

Hello docu-track99,

Can you please send the short gif or video that reproduces that problem. Or at least a screenshot?
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Post Reply