Summary
When developing a VB ActiveX DLL project that contains a Form, the Form needs to know about ArcMap. In that case, it is required to pass an Application object to the Form.
Procedure
Instructions provided describe how to Pass an Application object to a VB Form. When creating the Visual Basic ActiveX .DLL project in Step 1:
- Name the Class 'clsApp'
- Name the Project 'AoDemo'
- In Project Properties, enter 'ArcObjects Application' as the Project Description
- Save the class as clsApp.cls
- Save the project as AoDemo_clsApp.vbp
- Compile the .DLL as AoDemo_clsApp.dll
- Create a new Visual Basic ActiveX .DLL project that implements ICommand.
<a href='http://support.esri.com/en/knowledgebase/techarticles/detail/23923' target='_blank'>How To: Implement ICommand in Visual Basic</a> - Add a Form to the project and name the Form frmApp.
- In the General Declarations section of the frmApp code module, declare a module-level reference to the Application.
Code:
Option Explicit
Private m_pApp As IApplication
- In frmApp, add Public Get and Set properties for the Application.
Code:
Public Property Set Application(pApp As IApplication)
Set m_pApp = pApp
' *************************
' Add your custom code here
' *************************
End Property
Public Property Get Application() As IApplication
Set Application = m_pApp
End Property
- In the Class Module clsApp, rewrite the implementation code for the OnCreate method of ICommand:
Code:
Private Sub ICommand_OnCreate(ByVal hook As Object)
Set frmApp.Application = hook
End Sub
- In Class_Terminate of clsApp, remember to release the reference to the application.
Code:
Private Sub Class_Terminate()
Set frmApp.Application = Nothing
Unload frmApp
End Sub