Opening Visual Studio in ArcGIS

331
6
03-23-2012 10:50 AM
MikeMacRae
Regular Contributor
Hey folks....this is probably a really silly question, but...I can't figure it out.

I just installed the .NET SDk for ArcGIS 10. Before it installed, it prompted me to download MS Visual Studio 2008, which I did. I finally got the SDK to install and I want to start playing around. I haven't touched this stuff in about 3 years, so the last I remember in ArcGIS 9.2, you could open ArcMap, Go to the tools menu and there was a drop down that allowed you to open visual studio. I can't seem to find that at all. I went to open a visual studio project from the start menu, and all I see if a folder for and I can't even find the prompt to open Studio (See picture) Can someone point me in the right direction? I'm literally just getting started with developing again....so call me a noob 🙂

[ATTACH=CONFIG]12971[/ATTACH]

Thanks,
Mike
0 Kudos
6 Replies
NeilClemmons
Regular Contributor III
You're referring to the VBA editor, not Visual Studio.  ESRI no longer supports VBA but I believe you can still contact them and get a license for it if you want to use it for ArcGIS 10.  Starting with the 10.1 release, VBA will no longer be available.
0 Kudos
JimIsbell
New Contributor II
OK, noob:

Having already setup Visual Studio, now download and install the ArcGIS SDK for .NET, get all of your service packs on, then start learning about "Add-ins", new at 10.0.

And beware, even though ESRI says there is "a lot" of documentation about Add-ins available, I am finding it EXTREMELY TRICKY to create an add-in that can open a standard Windows Form properly. Actually, I can get it to open a form, but the form is not "owned" by the application window, so it floats independently and can get hidden behind the application window or other windows if I'm not careful. I have found a grand total of ZERO help or discussion of this topic so far.

Otherwise, the Add-in mechanism is very cool, and once I figure out my little form ownership issue, I think I'm going to love it.

While it is true that you can get the VBA license from ESRI for version 10.0 only, it is a pain in the rear to install because it requires a separate license key. Plus, if you used to keep any VBA code in the User Template code module, you will be surprised to learn that ESRI has eliminated the user template (MXT file) at version 10.0, so now you must save your code in the MXD Document module. You can actually save code in the Normal Template module (yes, there's still a Normal template, but no user templates) but then you cannot call such code from a toolbar button or tool.

Welcome to ESRI's new world order.
0 Kudos
RichardWatson
Regular Contributor III
You're referring to the VBA editor, not Visual Studio.  ESRI no longer supports VBA but I believe you can still contact them and get a license for it if you want to use it for ArcGIS 10.  Starting with the 10.1 release, VBA will no longer be available.


Neil, VBA is available in 10.1.  I have the licenses installed and have run it.
0 Kudos
NeilClemmons
Regular Contributor III
Actually, I can get it to open a form, but the form is not "owned" by the application window, so it floats independently and can get hidden behind the application window or other windows if I'm not careful. I have found a grand total of ZERO help or discussion of this topic so far.


Try searching the old forums:  http://forums.esri.com/forums.asp?c=93

You probably won't find anything specific to add-ins but you'll find plenty of threads on ArcObjects and general programming questions.

To display the form so that it floats on top of ArcMap but doesn't go behind it when the user clicks the main ArcMap window you need to call the overloaded Form.Show method and pass in the form's owner.  The owner reference must be of type IWin32Window.  ArcObjects doesn't expose a reference to the actual window but you can create your own class that implements IWin32Window as shown below.

    Public Class ModelessDialog
        Implements System.Windows.Forms.IWin32Window
        Private hwnd As System.IntPtr

        ''' <summary>
        ''' Returns the form handle.
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public ReadOnly Property Handle() As System.IntPtr Implements System.Windows.Forms.IWin32Window.Handle
            Get
                Return hwnd
            End Get
        End Property

        ''' <summary>
        ''' Constructor.
        ''' </summary>
        ''' <param name="handle">The form handle passed as an IntPtr</param>
        ''' <remarks></remarks>
        Public Sub New(ByVal handle As System.IntPtr)
            hwnd = handle
        End Sub

        ''' <summary>
        ''' Constructor.
        ''' </summary>
        ''' <param name="handle">The form handle passed as an integer</param>
        ''' <remarks></remarks>
        Public Sub New(ByVal handle As Integer)
            hwnd = CType(handle, IntPtr)
        End Sub
    End Class


To show the dialog you create a new instance of this class and pass it in.  All you need is a reference to the ArcMap application so that you can pass in its window handle to the class constructor.

Dim form As New yourForm
form.Show(New ModelessDialog(m_application.hWnd))
0 Kudos
NeilClemmons
Regular Contributor III
Neil, VBA is available in 10.1.  I have the licenses installed and have run it.


Thanks for the correction.  Looks like ESRI has had a change of plans.
0 Kudos
JimIsbell
New Contributor II
@Neil,

Thank you SO MUCH. This works PERFECTLY!

ESRI developers can sometimes really confound my sense of consistency. I found in the online documentation an "ArcGIS Explorer Style Guide for Developing Add-ins", in which it explains how the ESRI.ArcGISExplorer.Application namespace returns an IWin32Window reference. EXACTLY THE OBJECT I WOULD NEED for my ArcMap add-in. Except that the ArcMap add-in's My.ArcMap.Application object exposes just the hWnd integer property.

MyForm.Owner = My.ArcMap.Application.Window
How much easier THAT would have been! But I suppose I may find other uses for the ModelessDialog class.

Your help is MUCH appreciated!

-Jim
0 Kudos