I finally figured it out....
I was surfing through the various msdn references when I happened upon the
IComponentChangeService interface. This allowed me to know what interface to
use in order to capture an "control added" event. I then found an article
that showed how to manipulate a control via an add-in (which I used to hook
up the control's event).
http://support.microsoft.com/default.aspx?scid=kb;en-us;555170
Last, you need to capture the active window to hook up your event with the
active windows form in order to execute the event. It may not be the best
solution but I couldn't find anything else out there on this topic....
Here's the code: (be careful of copy and paste with GUID's....)
Imports Microsoft.Office.Core
imports Extensibility
imports System.Runtime.InteropServices
Imports EnvDTE
Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.Windows.Forms
#Region " Read me for Add-in installation and setup information. "
' When run, the Add-in wizard prepared the registry for the Add-in.
' At a later time, if the Add-in becomes unavailable for reasons such as:
' 1) You moved this project to a computer other than which is was
originally created on.
' 2) You chose 'Yes' when presented with a message asking if you wish to
remove the Add-in.
' 3) Registry corruption.
' you will need to re-register the Add-in by building the
MyFirstTestAddInSetup project
' by right clicking the project in the Solution Explorer, then choosing
install.
#End Region
<GuidAttribute("939E2A70-B167-4DDD-AF0F-D557BF88467C"),
ProgIdAttribute("MyFirstTestAddIn.Connect")> _
Public Class Connect
Implements Extensibility.IDTExtensibility2
Public WithEvents windowsEvents As EnvDTE.WindowEvents
Public WithEvents y As IComponentChangeService
Dim applicationObject As EnvDTE.DTE
Dim addInInstance As EnvDTE.AddIn
Public Sub OnBeginShutdown(ByRef custom As System.Array) Implements
IDTExtensibility2.OnBeginShutdown
End Sub
Public Sub OnAddInsUpdate(ByRef custom As System.Array) Implements
IDTExtensibility2.OnAddInsUpdate
End Sub
Public Sub OnStartupComplete(ByRef custom As System.Array) Implements
IDTExtensibility2.OnStartupComplete
End Sub
Public Sub OnDisconnection(ByVal RemoveMode As
Extensibility.ext_DisconnectMode, ByRef custom As System.Array) Implements
IDTExtensibility2.OnDisconnection
windowsEvents = Nothing
y = Nothing
End Sub
Public Sub OnConnection(ByVal application As Object, ByVal connectMode
As Extensibility.ext_ConnectMode, ByVal addInInst As Object, ByRef custom As
System.Array) Implements IDTExtensibility2.OnConnection
applicationObject = CType(application, EnvDTE.DTE)
addInInstance = CType(addInInst, EnvDTE.AddIn)
Dim events As EnvDTE.Events
events = applicationObject.Events
windowsEvents = CType(events.WindowEvents(Nothing),
EnvDTE.WindowEvents)
' When run, the Add-in wizard prepared the registry for the Add-in.
' At a later time, the Add-in or its commands may become unavailable
for reasons such as:
' 1) You moved this project to a computer other than which is was
originally created on.
' 2) You chose 'Yes' when presented with a message asking if you
wish to remove the Add-in.
' 3) You add new commands or modify commands already defined.
' You will need to re-register the Add-in by building the
MyFirstTestAddInSetup project,
' right-clicking the project in the Solution Explorer, and then
choosing install.
' Alternatively, you could execute the ReCreateCommands.reg file the
Add-in Wizard generated in
' the project directory, or run 'devenv /setup' from a command prompt.
End Sub
Private Sub windowsEvents_WindowActivated(ByVal GotFocus As
EnvDTE.Window, ByVal LostFocus As EnvDTE.Window) Handles
windowsEvents.WindowActivated
Dim objIDesignerHost As IDesignerHost
Dim objIComponent As IComponent
Dim colPropertyDescriptorCollection As PropertyDescriptorCollection
Dim objPropertyDescriptor As PropertyDescriptor
Dim objIContainer As IContainer
Dim objIServiceProvider As IServiceProvider
' Get the designer host
objIDesignerHost = DirectCast(GotFocus.Object, IDesignerHost)
' Get the service provider
objIServiceProvider = DirectCast(objIDesignerHost, IServiceProvider)
' Get the container
objIContainer = objIDesignerHost.Container
For Each objIComponent In objIContainer.Components
If TypeOf objIComponent Is Form Then
y =
CType(objIServiceProvider.GetService(GetType(IComponentChangeService)),
IComponentChangeService)
Exit For
End If
Next
End Sub
Private Sub y_ComponentAdded(ByVal sender As Object, ByVal e As
System.ComponentModel.Design.ComponentEventArgs) Handles y.ComponentAdded
MessageBox.Show("Component Added")
End Sub
End Class
Then in the Correct
> I had a VB6 add-in that caught when a control was being added to any form in
> the solution. I am trying to rewrite this add-in in VS.Net 2K3 and I don't
[quoted text clipped - 4 lines]
> Thanks,
> Kevin
Carlos J. Quintero [VB MVP] - 20 Sep 2005 10:34 GMT
I'm glad that the KB article helped ;-)

Signature
Best regards,
Carlos J. Quintero
MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com
>I finally figured it out....
>
[quoted text clipped - 152 lines]
>> Thanks,
>> Kevin
Kevin - 20 Sep 2005 18:45 GMT
Your site and KB is much appreciated. :)
> I'm glad that the KB article helped ;-)
>
[quoted text clipped - 154 lines]
> >> Thanks,
> >> Kevin