Author Topic: Windows DEV NOOB  (Read 4568 times)

Chris Tatem

  • EA User
  • **
  • Posts: 30
  • Karma: +0/-0
    • View Profile
Windows DEV NOOB
« on: February 19, 2010, 06:34:05 am »
Where can I look to find the basics to windows development sufficient to build and deploy the Reporting Example for Automation Interface?  (Not trying to get a tutorial on the entire MS SDK, just getting started in a simple, VB -> ActiveX DLL sufficient to become an add-in)

I have an extensive programming background, so it's not the language problem it's the IDE/Build process that I can't figure out.  I don't have vb6, but have Visual Studio 2008 (think I can find Visual Studio 6.0 if that would help).  Upgrading the (downloaded) vbp provided results in over 100 errors, so that can't be the right way to approach this.  I can't seem to figure out how to "run" or "build" the implied DLL from within VB in Word (after importing the .bas files, there is a missing "link" to the add-in)... just don't know where to look next... any pointers/help in getting started with this process would be appreciated...

I really (think I) want the Word doc integration and this example is a perfect start...

thanks - chris

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: Windows DEV NOOB
« Reply #1 on: February 19, 2010, 11:36:30 am »
If you are programming in VB.Net, the closest project framework for you to start with would be the C# example on our website.  The VB6 examples will probably not convert quite as easily.

The basic process is
1) create a new DLL project
2) add reference to "Interop.EA.dll" file in your EA install directory
3) open the project properties and enable "Register for COM Interop"
4) implement the following methods in your code:

Public Function EA_Connect(ByVal Repository As EA.Repository) As String
Public Function EA_GetMenuItems(ByVal Repository As EA.Repository, ByVal Location As String, ByVal MenuName As String) As Object
Public Sub EA_GetMenuState(ByVal Repository As EA.Repository, ByVal Location As String, ByVal MenuName As String, ByVal ItemName As String, ByRef IsEnabled As Boolean, ByRef IsChecked As Boolean)
Public Sub EA_MenuClick(ByVal repository As EA.Repository, ByVal Location As String, ByVal MenuName As String, ByVal ItemName As String)

From there, you should be able to look at other example Add-Ins and the API documentation to flesh out the rest of your Add-In.  Remember that you will also need to add a registry key for your Add-In as documented in the SDK.

If you specifically want the functionality of the VB6 example project however, you will either need to get Visual Basic 6.0 installed, or manually re-write most of the code in VB.Net.

HTH.

fwoolz

  • EA User
  • **
  • Posts: 435
  • Karma: +0/-0
  • We have met the enemy, and he is us.<Pogo, 1970>
    • View Profile
Re: Windows DEV NOOB
« Reply #2 on: February 19, 2010, 01:44:11 pm »
I've done several add-in projects for EA using Visual Studio (several versions) and C#, and the process is really straightforward. I usually start with a "Connector" class that is registered for COM interoperability (a project properties option; just a checkbox, in fact, so no special coding is required) and event handlers for the various EA events along with methods for connecting, providing the menu interface with EA, etc. I then dish out work to supporting classes, including GUI elements, based on EA events handled by the Connector class. All of it is laid out well in the EA SDK help, BTW.

The beauty of writing add-ins for EA using the .NET framework is that you don't need to get involved in the complicated mess that is COM and ActiveX - the .NET COM interoperability layer takes care of that for you.

Cheers,
Fred W
Fred Woolsey
Interfleet Technology Inc.

Always be ready to laugh at yourself; that way, you beat everyone else to the punch.


Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Windows DEV NOOB
« Reply #3 on: February 19, 2010, 05:57:25 pm »
To add to that.
There is an example addin in C# available from the website that already contains the necesarry operations to be used by EA.
Use that as a template for your own addin class.
Only this class needs to bebuild in a COM visible dll. (This means it has to be registerred using regasm, but VS takes care of this for you if you set the appropriate build config settings.)
The entry in the registry tells EA where to look for your addin.
The rest of your classes can be build as a regular C# dll.

Geert


Chris Tatem

  • EA User
  • **
  • Posts: 30
  • Karma: +0/-0
    • View Profile
Re: Windows DEV NOOB
« Reply #4 on: February 20, 2010, 12:22:50 am »
Thanks all, diving in!

cwt

fwoolz

  • EA User
  • **
  • Posts: 435
  • Karma: +0/-0
  • We have met the enemy, and he is us.<Pogo, 1970>
    • View Profile
Re: Windows DEV NOOB
« Reply #5 on: February 20, 2010, 07:28:43 am »
To add to Geert's comments:

I did forget the bit about adding the registry entry that EA needs to find the add-in. Here's a sample .reg file showing where in the registry you would need to place the entry for your add-in:

Code: [Select]
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Sparx Systems\EAAddins\Specifyx]
@="Specifyx.Connector"
In the sample case, the name of the add-in is "Specifyx", and the name of the add-in assembly is "Specifyx.Connector". This would be the assembly name of the .dll for the COM-visible class created to "wire up" your add-in to EA.

Fred W
Fred Woolsey
Interfleet Technology Inc.

Always be ready to laugh at yourself; that way, you beat everyone else to the punch.


Chris Tatem

  • EA User
  • **
  • Posts: 30
  • Karma: +0/-0
    • View Profile
Re: Windows DEV NOOB
« Reply #6 on: February 20, 2010, 08:32:54 am »
Thanks all, I truly am off and running :)

One bit that wasn't obvious to me, that I figured out, in addition to what Aaron noted on project setup, at least in Visual Studio 2008 in order to make the assembly COM-Visible, you have to note that it two places, in Project->{name of your Assembly} Properties, then on the General "tab" click on Assembly Properties and make sure "Make assembly COM-visible" is checked.  AND on the Build "tab" be sure "Register for COM-Interop" is checked.  VS seems to do some good stuff for you then.  This seems to make a "Type" available to be registered.

The second bit eliminates the RegAsm warning:
RegAsm : warning RA0000 : No types were registered

and connects the dots.  (told you I was a NOOB :) )

That alone with the registry keys, and RegAsm got me rolling.

cwt

fwoolz

  • EA User
  • **
  • Posts: 435
  • Karma: +0/-0
  • We have met the enemy, and he is us.<Pogo, 1970>
    • View Profile
Re: Windows DEV NOOB
« Reply #7 on: February 20, 2010, 10:01:58 am »
Chris,

Actually, AFAIR, VS 2008 should do the RegAsm work for you itself. One point to note is that you will need to specify the code base (full path to your dll) if doing manual RegAsm of an assembly, at least if you want to be able to install the dll somewhere other than the same directory as the EA executable.

Fred W
Fred Woolsey
Interfleet Technology Inc.

Always be ready to laugh at yourself; that way, you beat everyone else to the punch.