2009-07-06 5 views
0

Utilisé l'Assistant Nouveau complément pour créer un projet complémentaire Visual C++/ATL.
code généré:Extension ATL, VS2008: Ajout du gestionnaire d'événements à WindowEvents

HRESULT hr = S_OK; 
pApplication->QueryInterface(__uuidof(DTE2), (LPVOID*)&m_pDTE);  
pAddInInst->QueryInterface(__uuidof(AddIn), (LPVOID*)&m_pAddInInstance);` 

avoir les évènements objet et les WindowEvents:

m_pDTE->get_Events(&m_pEvents); 
m_pEvents->get_WindowEvents(0, &m_pWinEvents); 

Comment ajouter un gestionnaire d'événements?

if (NULL != m_pWinEvents) { 
    m_pWinEvents += ???? 
} 

Merci pour toutes les allusions ou références ...

Mise à jour, en essayant la suggestion de Alien01:

m_pWinEvents->WindowActivated += new _dispWindowEvents_WindowActivatedEventHandler(this.WindowActivated); 

1> ...
Compiler 1> Connect.cpp
1> c: \ work \ visstudio_addin \ cbaddin3 \ cbaddin3 \ connect.cpp (43): erreur C2039: 'WindowActivated': n'est pas membre de 'EnvDTE :: _ WindowEvents'
1> c: \ work \ visstudi o_addin \ cbaddin3 \ cbaddin3 \ debug \ dte80a.tlh (1006): voir la déclaration de 'EnvDTE :: _ WindowEvents'
1> c: \ work \ visstudio_addin \ cbaddin3 \ cbaddin3 \ connect.cpp (43): erreur C2061: syntaxe erreur: identifiant '_dispWindowEvents_WindowActivatedEventHandler'

+0

Avez-vous défini la fonction WindowActivated dans votre classe? – anand

+0

Oui, j'ai une fonction WindowActivated() dans ma classe. Je crois que les messages d'erreur font référence à m_pWinEvents-> WindowActivated et _dispWindowEvents_WindowActivatedEventHandler. – Number8

Répondre

0
You can try using 

m_pWinEvents. WindowCreated += 
    new _dispWindowEvents_WindowCreatedEventHandler(this.WindowCreated); 

puis définir gestionnaire

public : 
    void WindowCreated(EnvDTE.Window window) 
    { 
     // some code 
    } 
+0

Merci pour la réponse, ajouté votre suggestion à OP. – Number8

+0

Lien MSDN pour plus d'informations http://msdn.microsoft.com/fr-fr/library/ms165650(VS.80).aspx Code Lien de projet http://www.codeproject.com/KB/macros/ vsnowediting.aspx – anand

+0

Le lien de bibliothèque MSDN décrit C#. J'ai cette construction de version réussie (il y a un problème en la chargeant.) Le lien CodeProject utilise également C# (malgré ce que disent ses balises). Merci pour les liens, cependant. – Number8

Questions connexes