vb9666
asked on
AxAcroPDFLib throws exception when containing form is MDI child
I'm working on what should be a very simple project, but I'm running into a world of troubles.
I have an MDI parent form which displays a list of PDF files located on a mapped network drive. When the user double-clicks a file, an MDI child form opens to show the PDF.
The only control on the child form is of the type "Adobe Acrobat 7.0 Browser Control Type Library 1.0".
When I call the LoadFile method of the pdf viewer control, it throws this exception: First-chance exception at 0x1000847c in Foo.exe: 0xC0000005: Access violation reading location 0x00000008.
If I go into the MDI parent's code and remove the line "frmMDIChild.ParentForm = Me" and allow the pdf viewer's form to open in its own window I do not get the exception.
Doing a little googling I have found others who have the same problem but I have not found a solution anywhere.
Using a WebBrowser control to display the PDFs is not an option in this case.
Any help would be appreciated. Thanks!
I have an MDI parent form which displays a list of PDF files located on a mapped network drive. When the user double-clicks a file, an MDI child form opens to show the PDF.
The only control on the child form is of the type "Adobe Acrobat 7.0 Browser Control Type Library 1.0".
When I call the LoadFile method of the pdf viewer control, it throws this exception: First-chance exception at 0x1000847c in Foo.exe: 0xC0000005: Access violation reading location 0x00000008.
If I go into the MDI parent's code and remove the line "frmMDIChild.ParentForm = Me" and allow the pdf viewer's form to open in its own window I do not get the exception.
Doing a little googling I have found others who have the same problem but I have not found a solution anywhere.
Using a WebBrowser control to display the PDFs is not an option in this case.
Any help would be appreciated. Thanks!
ASKER
Idle_Mind, thanks for your comment. I am sorry, I mistakenly wrote ParentForm in my question when in the code it actually sets MdiParent.
I will try your second suggestion now.......
I will try your second suggestion now.......
ASKER
I tried Idle_Mind's suggestion of setting the MdiParent property after loading the pdf. After loading the PDF, I have the program sleep for 5 seconds so that I can visually verify that the PDF was loaded. It indeed was. When the program finished sleeping and set the child form's MdiParent, the viewer no longer displayed the document but was just a white box. No exceptions were thrown.
frmR.Show()
frmR.LoadPDF()
frmR.Refresh()
System.Threading.Thread.Sl eep(5000)
frmR.MdiParent = Me
frmR.Refresh()
frmR.Show()
frmR.LoadPDF()
frmR.Refresh()
System.Threading.Thread.Sl
frmR.MdiParent = Me
frmR.Refresh()
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
More of a workaround than a solution, but it works for me! Thanks!!
Doubt this will fix the problem...
...but if you want an Mdi Child Form then change:
frmMDIChild.ParentForm = Me
To:
frmMDIChild.MdiParent = Me
A possible "kludge" solution would be to open up the form normally and then make it an MDI child AFTER loading the PDF?