MDI children forms

PDF-XChange Viewer SDK for Developer's
(ActiveX and Simple DLL Versions)

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

wcarlsrud
User
Posts: 8
Joined: Wed Jan 20, 2016 9:55 pm

MDI children forms

Post by wcarlsrud »

I'm getting an initialization error when accessing the PDF viewer in a MDI child form.
If the form is not made a MDI child of the parent the control works fine.
Is there a setting or flag that I'm missing?
User avatar
Will - Tracker Supp
Site Admin
Posts: 6815
Joined: Mon Oct 15, 2012 9:21 pm
Location: London, UK

Re: MDI children forms

Post by Will - Tracker Supp »

Hi wcarlsrud,

Thanks for the post - I'm not sure that I understand the issue. Are you using our SDK, or the end user app? Also please clarify what product, specifically, you are using, as you have posted in the Editor forum but are referencing the Viewer.

Lastly please provide any relevant sample documents, such as a copy of a working form and one that shows the error, as well as step-by-step instructions to reproduce.

Thanks,
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

Will Travaglini
Tracker Support (Europe)
Tracker Software Products Ltd.
http://www.tracker-software.com
wcarlsrud
User
Posts: 8
Joined: Wed Jan 20, 2016 9:55 pm

Re: MDI children forms

Post by wcarlsrud »

AxInterop.PDFXEdit.dll v1.0.0.0
Interop.PDFXEdit.dll v1.0.0.0

I am using the AxPXV_Control

When I place the control on a 'regular' form the control works as expected.

When it is on a MDI child form the control throws an error when it is referenced.

at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at AxPDFXEdit.AxPXV_Control.OpenDocFromPath(String sSrcPath)
at ADC_PDF_Launcher.frmTracker.frmTracker_Load(Object sender, EventArgs e) in C:\SourceCode\VS2015\ADC_PDF_Launcher.NET\frmTracker.vb:line 17

here is the code fragment:

licKeyDEMO = "demo key was here"
AxPXV_Control1.SetLicKey(licKeyDEMO)
AxPXV_Control1.OpenDocFromPath("C:\users\carlsw\desktop\Sample.pdf")
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: MDI children forms

Post by Sasha - Tracker Dev Team »

Hello wcarlsrud,

OK, so you have the Editor SDK not the Viewer one.
Please provide a small working sample in attachment so that we can debug it an tell you what the problem is.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
wcarlsrud
User
Posts: 8
Joined: Wed Jan 20, 2016 9:55 pm

Re: MDI children forms

Post by wcarlsrud »

I have a sample vs2015 solution. the zip file is too large to attach. Where can I email it?
wcarlsrud
User
Posts: 8
Joined: Wed Jan 20, 2016 9:55 pm

Re: MDI children forms

Post by wcarlsrud »

Got rid of the big PDF and put in a placeholder. :lol:
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: MDI children forms

Post by Sasha - Tracker Dev Team »

Hello wcarlsrud,

Will look at it.
You've pasted sample with license key. Please do NOT post your license key here, or we will be forced to deactivate it.
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
wcarlsrud
User
Posts: 8
Joined: Wed Jan 20, 2016 9:55 pm

Re: MDI children forms

Post by wcarlsrud »

That is the 'demo' license key from the sample application.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: MDI children forms

Post by Sasha - Tracker Dev Team »

Ok my bad - sorry for the inconvenience.
I've inspected the problem and there was a 'Wrong Thread' exception that means that the control creation and the methods used are in different threads. I do not know why this occurred but will try to find out. Maybe you could provide some information in this respect?

HTH,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
wcarlsrud
User
Posts: 8
Joined: Wed Jan 20, 2016 9:55 pm

Re: MDI children forms

Post by wcarlsrud »

We are evaluating the product to determine if this is 'better' than another vendor's

I can only point to the sample solution and say that the error only appears to happen when the form is launched with the MDI parent property set to the MDI parent.

I'm not sure why that would cause the control to fail when it tries to load a PDF. The MDI child form will display with the control as long as a PDF is not loaded.
User avatar
Vasyl-Tracker Dev Team
Site Admin
Posts: 2353
Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada

Re: MDI children forms

Post by Vasyl-Tracker Dev Team »

Hi wcarlsrud.

We investigated your case and found some issues on our side. When VB creating MDI-Child with embedded ActiveX control it does one strange trick: it creates ActiveX-object, then instantiates UI-control based on this object, then destroys this control and creates new again for the same ActiveX object. But unfortunately, currently we are not supported correctly the re-creating of UI-control for the same ActiveX-object. We will fix this issue in the next build.

Also we have some tips for case when app. requires using of multiple our ActiveX Control in the same time.

1. Add code to initialize/uninitialize SDK only once time, otherwise might be next situation:

Code: Select all

Controls.Add(AxPXV_Control1) // instantiating of first control initializes SDK
Controls.Add(AxPXV_Control2)
...
...
AxPXV_Control2.Destroy()
AxPXV_Control1.Destroy() // destroying of last control uninitializes SDK
....
Controls.Add(AxPXV_Control3) // AGAIN: instantiating of first control initializes SDK
...
AxPXV_Control3.Destroy() // destroying of last control uninitializes SDK

Multiple init/uninit of SDK will definitely slow down performance of your app. So exists simple solution to do it once only:

MainForm::Load()
{
	Dim licKey As String = String.Empty

	Try
		PXV_Inst = New PDFXEdit.PXV_Inst()
		PXV_Inst.Init(Nothing, licKey)
	Catch ex As Exception
	End Try
}

MainForm::Closed()
{
	If PXV_Inst IsNot Nothing Then
		Try
			PXV_Inst.Shutdown()
		Catch ex As Exception
		End Try
		PXV_Inst = Nothing
	End If
}
- now, all ActiveX Controls, instantiated between MainForm::Load()/MainForm::Closed(), will only increment/decrement special counter of SDK-initializations.

2. other note: in case with creating of MDI-child is too early to open document(and to use many other functions) in context of Form::Load(). In this moment the ActiveX-object isn't a UI-control. Currently we have no idea why. We found simple workaround for that:

Code: Select all

MDIChild::Load()

	// Init()
}

MDIChild::Init()
{
	Try
		AxPXV_Control1.OpenDocFromPath("D:\TestFile.pdf")
	Catch ex As Exception
	End Try
}

MainFrame::OnCreateMDIChild()
{
	MDIChild.MdiParent = Me
	MDIChild.Show()

	MDIChild.Init()
}
HTH.
Vasyl Yaremyn
Tracker Software Products
Project Developer

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
wcarlsrud
User
Posts: 8
Joined: Wed Jan 20, 2016 9:55 pm

Re: MDI children forms

Post by wcarlsrud »

I'm not able to make the work-around for #2 (the MDI child) actually work.

When I try to load the control in any of the available events, it appears to just ignore the command.
In the Load event, it throws the reflection error.
wcarlsrud
User
Posts: 8
Joined: Wed Jan 20, 2016 9:55 pm

Re: MDI children forms

Post by wcarlsrud »

Got it figured out. I had to create the control in the parent MDI and manually add it to the child form.

When is your next build scheduled to be released? :D
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: MDI children forms

Post by Sasha - Tracker Dev Team »

Hello wcarlsrud,

Glad you got it figured out. As far as I know - it should be in February (though I'm not certain).

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ