Home GIT Development ESRI ArcGIS Add custom menu to ArcMap main menu?
Add custom menu to ArcMap main menu? Print

03 March 2009 Git4You:

After the vietnamese edition of this tutorial has been released at Git4You Vietnamese Fourm, some foreign visitors ask me for the english. And this is the english one, will go through a tutorial for adding custom menu to ArcMap main menu with VB.NET 2008

Pre-requirements:

- Visual Basic .NET SDK 2008
- ArcGIS Desktop 9.3
- ArcGIS Desktop SDK 9.3 for .NET

You may follow these steps:


1. Create new VB.NET project and select Class Library (ArcMap) template as image below:

 



Locate your workspace on disk to save your project, then click OK to continue

2. On the next dialog, add ESRI.ArcGIS.Framework to your project and click Finish.

3. Open your Solution Explorer and delete Class1.vb. Then add new item. Navigate to the ArcGIS Template and choose Base Menu. It will automatically name new item with ArcGISClass1.vb. Leave it as default, click Add to close the dialog.

 

 

 

4. The wizard will ask you about the type of Base Menu. In this case, we create for ArcMap.

5. Locate to the ArcGISClass1.vb and double click on this to open code window

6. Find:

_________________
Public Sub New()
'
'TODO: Define your menu here by adding items
'
//AddItem("esriArcMapUI.ZoomInFixedCommand")
//BeginGroup() 'Separator
//AddItem("{FBF8C3FB-0480-11D2-8D21-080009EE4E51}", 1) 'undo command
//AddItem(New Guid("FBF8C3FB-0480-11D2-8D21-080009EE4E51"), 2) 'redo command

End Sub

_________________

Replace with:

_________________
Public Sub New()
'
'TODO: Define your menu here by adding items
'
AddItem("esriArcMapUI.ZoomInFixedCommand")
BeginGroup() 'Separator
AddItem("{FBF8C3FB-0480-11D2-8D21-080009EE4E51}", 1) 'undo command
AddItem(New Guid("FBF8C3FB-0480-11D2-8D21-080009EE4E51"), 2) 'redo command
End Sub
_______________
__

7. Find:

_________________

Public NotInheritable Class ArcGISMenu1
Inherits BaseMenu

_________________

Then replace with:
_________________

Public NotInheritable Class ArcGISMenu1
Inherits BaseMenu
Implements ESRI.ArcGIS.Framework.IRootLevelMenu

_________________

8. Then find:
_________________

Public Overrides ReadOnly Property Caption() As String
Get
'TODO: Replace bar caption
Return "My VB.Net Menu"
End Get
End Property

_________________

Replace with

_________________

Public Overrides ReadOnly Property Caption() As String
Get
'TODO: Replace bar caption
Return "Git4You BaseMenuDemo" //or what you want to name the caption
End Get
End Property

_________________

9. Build and start debugging. This will run ArcMap

10. Access Tools menu from ArcMap, navigate to Customize to open Customize dialog. Then click Commands Tab

11. Locate [Menu] item on the left, find Git4You BaseMenuDemo on the right, as image below:

 


 

12. Drag "Git4You BaseMenuDemo" to ArcMap main menu:

 

Now review your code to understand program behavior. You may post your question into Git4You English Forum if you want. A demo project is avalable in Download Center. Good luck !

__________________________
Written by Mr. Bic Phuong
 

 
 

Online GIS Consultant

Email Subscription

Enter your email address:

Delivered by FeedBurner

GIT Images

GEODESYYELLOWSTONE-DESKTOP-RESOLUTION.png

Who's Online

We have 3 guests online