Pdf et sub New Erreur 'System.Windows.Forms.AxHost+InvalidActiveXStateException'

Résolu
Fabasia Messages postés 45 Date d'inscription mercredi 26 mars 2008 Statut Membre Dernière intervention 17 août 2012 - 23 mars 2011 à 11:58
Fabasia Messages postés 45 Date d'inscription mercredi 26 mars 2008 Statut Membre Dernière intervention 17 août 2012 - 23 mars 2011 à 12:36
Mon code génère une erreur que je ne peux comprendre ...

Dans la Form2, je fais un form4.dispose, ce qui lance la sub new de form4 et genere une erreur 'System.Windows.Forms.AxHost+InvalidActiveXStateException' du fait de Dim AcroPDF_document As New AxAcroPDFLib.AxAcroPDF

Si je crée moi même le controle AcroPDF_document dans la form pas de pb, si le programme le crée dans la sub new --> Pb ????

Comment résoudre ca ? Merci


Mon code :

Public Class Form4

    Sub New()

        ' Cet appel est requis par le Concepteur Windows Form.
        InitializeComponent()

        ' Ajoutez une initialisation quelconque après l'appel InitializeComponent().

        'La form fait 90% de la taille de l'écran
        Size = New Size(CInt(0.9 * My.Computer.Screen.WorkingArea.Width), CInt(0.9 * My.Computer.Screen.WorkingArea.Height))

        FormBorderStyle = Windows.Forms.FormBorderStyle.FixedDialog
        MaximizeBox = False
        MinimizeBox = False
        StartPosition = FormStartPosition.CenterScreen
        TopMost = True

        Dim AxAcroPDF_document As New AxAcroPDFLib.AxAcroPDF
        AxAcroPDF_document.Name = "AxAcroPDF_document"
        AxAcroPDF_document.src = Nothing
        AxAcroPDF_document.Dock = DockStyle.Fill
        AxAcroPDF_document.Visible = True
        AxAcroPDF_document.setShowToolbar(False)
        AxAcroPDF_document.setShowScrollbars(True)
        Controls.Add(AxAcroPDF_document)

.......


1 réponse

Fabasia Messages postés 45 Date d'inscription mercredi 26 mars 2008 Statut Membre Dernière intervention 17 août 2012
23 mars 2011 à 12:36
Pb resolu en maintant le code suivant dans la Sub Form4_Load et pas dans la sub New

                Dim AxAcroPDF_document As AxAcroPDFLib.AxAcroPDF = CType(Me.Controls("AxAcroPDF_document"), AxAcroPDFLib.AxAcroPDF)
                AxAcroPDF_document.src = question.document
                AxAcroPDF_document.Dock = DockStyle.Fill
                AxAcroPDF_document.Visible = True
                AxAcroPDF_document.setShowToolbar(False)
                AxAcroPDF_document.setShowScrollbars(True)
3
Rejoignez-nous