Author Topic: Adding ActiveX Object via addwindow method  (Read 9655 times)

Mithal

  • EA User
  • **
  • Posts: 27
  • Karma: +0/-0
    • View Profile
Adding ActiveX Object via addwindow method
« on: November 17, 2010, 09:49:10 pm »
Hi I have created a active X control using VB 6.

i have registered it and now trying to use it in my EA Addin.

i am using the follwing code:
Repository.AddWindow("Test Window", "Project1.UserControl1");
the code executes with no exception raised but the window does not get added, i even checked under the work space layout.

Does the control have to be written in .NET?

If i try to add it using:
Repository.AddTab("Test", "Project1.UserControl1");

i get the "attempted to read or arite protected memory error...."

Please can someone help with this or maybe point me to the correct Microsoft articles that shows how to create a OCX in .NET

Thanks in advance. :)

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Adding ActiveX Object via addwindow method
« Reply #1 on: November 18, 2010, 12:42:34 am »
Mithal,

I think there is another topic about the addWindow somewhere.
That might be of help.

Geert

Mithal

  • EA User
  • **
  • Posts: 27
  • Karma: +0/-0
    • View Profile
Re: Adding ActiveX Object via addwindow method
« Reply #2 on: November 18, 2010, 06:11:18 pm »
Thanks for the reply.

I have made progress with writing the .NET usercontrol and it works fine if i use it with the AddTab method available from the repository

i followed the article from this link
http://www.sparxsystems.com/uml_tool_guide/sdk_for_enterprise_architect/creatingacustomview.htm

The problem i have i can add the user control using the addwindow method which works, the code is like this

 m_MyControl = (Test.UserControl1)Repository.AddWindow("SYSPRO Window", "Test.UserControl1");

 m_MyControl.BringToFront();
IntPtr myPtr = m_MyControl.Handle;

Now i cannot find my window, i did look under the Workspace Layouts and there is nothing.  How can i trouble shoot this
I am on version 8.0 of Enterprise Architecture. Build 856.

Please Help.

Thanks in Advence.

Mithal

  • EA User
  • **
  • Posts: 27
  • Karma: +0/-0
    • View Profile
Re: Adding ActiveX Object via addwindow method
« Reply #3 on: November 18, 2010, 06:13:12 pm »
Thanks for the reply.

I have made progress with writing the .NET usercontrol and it works fine if i use it with the AddTab method available from the repository

i followed the article from this link
http://www.sparxsystems.com/uml_tool_guide/sdk_for_enterprise_architect/creat...

The problem i have i can add the user control using the addwindow method which works, the code is like this

m_MyControl = (Test.UserControl1)Repository.AddWindow("SYSPRO Window", "Test.UserControl1");

m_MyControl.BringToFront();
IntPtr myPtr = m_MyControl.Handle;

Now i cannot find my window, i did look under the Workspace Layouts and there is nothing.  How can i trouble shoot this
I am on version 8.0 of Enterprise Architecture. Build 856.

Please Help.

Thanks in Advence.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Adding ActiveX Object via addwindow method
« Reply #4 on: November 18, 2010, 07:40:49 pm »
Mithal,

It should have been added to the View|Add-in Windows

Geert

Mithal

  • EA User
  • **
  • Posts: 27
  • Karma: +0/-0
    • View Profile
Re: Adding ActiveX Object via addwindow method
« Reply #5 on: November 18, 2010, 07:50:22 pm »
Ah Thank you.

Sébastien Jahan

  • EA User
  • **
  • Posts: 21
  • Karma: +0/-0
    • View Profile
Re: Adding ActiveX Object via addwindow method
« Reply #6 on: July 06, 2011, 01:47:24 am »
Hi Geert, hi Mithal.

I have the same problem Mithal encountered with the addTab, i get an AccessViolationException telling me that i try to access some protected memory.

Repository.AddTab("OEA Export", "Export.TestPan");
TestPan is a UserControl, and Export is the namespace of the class.
Is it the right syntax? How could i go through this problem?

Thank you very much by advance,

SJ.

mcinar

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
    • View Profile
Re: Adding ActiveX Object via addwindow method
« Reply #7 on: July 07, 2011, 06:28:20 am »
Hi all,

I am having a problem about adding a add-in window to Enterprise Architect.
First of all, I am using Visual Studio 2010 and C# as the language.
 I just followed the code in the following link:
http://www.sparxsystems.com/uml_tool_guide/sdk_for_enterprise_architect/creatingacustomview.htm

but the only problem is, I don't understand how I am going to use UserControl1.
So, "  UserControl1 m_MyControl;" I could not created an instance of Usercontrol to hold the pointer of the addWindow, to manipulate it.

Actually, I tried to create an ActiveX custom control object, but it seems so complicated that I tried many many times but none of them ended up with something works.

At this point I really appreciate any help that might give me a clue to where to start. I only need to create the object to hold the pointer of addWindow() and manipulate it as I need.

I even created some simple class, and registered it's .dll file with regasm.exe to the registry, but I am still not able to create an instance of the class that I registered, in my code.

I dont know if I need to add some "using" clause?

I appreciate your help.
Thanks,

Murat.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Adding ActiveX Object via addwindow method
« Reply #8 on: July 07, 2011, 01:38:17 pm »
I've added a working example of this to my example add-in at
https://github.com/GeertBellekens/Enterprise-Architect-Add-in-Framework

Geert

mcinar

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
    • View Profile
Re: Adding ActiveX Object via addwindow method
« Reply #9 on: July 07, 2011, 02:31:58 pm »
Quote
I've added a working example of this to my example add-in at
https://github.com/GeertBellekens/Enterprise-Architect-Add-in-Framework

Geert

Thanks a lot, I appreciate.

Sébastien Jahan

  • EA User
  • **
  • Posts: 21
  • Karma: +0/-0
    • View Profile
Re: Adding ActiveX Object via addwindow method
« Reply #10 on: July 07, 2011, 07:16:58 pm »
Nothing about addTab? If you prefer, i can create a thread on that topic. That's quite annoying, i really don't understand why it works on my boss computer (EA 7.5) and on my dev and test environment (EA 8), it crashes :(
On my dev env, i'm using Visual Studio, so if i'm not wrong there is no COM register issue liely to happen, right?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Adding ActiveX Object via addwindow method
« Reply #11 on: July 07, 2011, 07:29:18 pm »
Sébastien,

I think AddTab works the same way as AddWindow.
It's not because you are using Visual Studio that you can't have COM registration issues, but a crash usually has other reasons.
I had an issue recently with EA crashing (hard) when I was trying to use the Repository object before the model was fully loaded.
You have to be especially careful with the EA_OnContextItemChanged event and the likes, since they can be launched by EA before the Repository object is ready to be used.
I found that the EA_FileOpen event is a good one to indicate a fully loaded and ready Repository object, so I used that to flip a switch on my add-in class like this
Code: [Select]
       public void EA_FileOpen(EA.Repository Repository)
        {
            this.EAFullyLoaded = true;
        }
Then in the EA_OnContextItemChanged I do following:
 
Code: [Select]
      public void EA_OnContextItemChanged(EA.Repository Repository, string GUID, EA.ObjectType ot)
        {
            if (this.EAFullyLoaded)
            {
             // do useful stuff

Geert

Sébastien Jahan

  • EA User
  • **
  • Posts: 21
  • Karma: +0/-0
    • View Profile
Re: Adding ActiveX Object via addwindow method
« Reply #12 on: July 07, 2011, 07:45:10 pm »
I'll try that but i'm not using the OnContextItemChanged event. The only thing we're doing is

public String EA_Connect(EA.Repository Repository)
            {
            m_RepositoryView = Repository.AddTab("OEA Browser", "OEA.TestPan") as UserControl;
                  return "OEASparxConnector.AddIn started";
            }

OEA being my namespace, and TestPan a classic UserControl (that does nothing except displaying a empty text field and a button). What is odd is that this kind of code works on another computer, that's quite confusing  :-/
« Last Edit: July 07, 2011, 07:48:13 pm by sjahan »

Sébastien Jahan

  • EA User
  • **
  • Posts: 21
  • Karma: +0/-0
    • View Profile
Re: Adding ActiveX Object via addwindow method
« Reply #13 on: July 07, 2011, 07:52:13 pm »
Thank you very much Geert, that made the trick!
I moved my call to addTab only when EA detects a project is loaded and it seems to work great now!

Have a very nice day and thank you again for your help,

SJ.

Nabil

  • EA User
  • **
  • Posts: 147
  • Karma: +5/-2
    • View Profile
    • View My LinkedIn Profile Here
Re: Adding ActiveX Object via addwindow method
« Reply #14 on: September 10, 2015, 04:13:35 pm »
Hello Guys,

Objective:
Use AddWindow to Call a User Control within the ActiveX Control window where the Addin is installed as an application


I have an issue where the AddWindow works properly from Visual Studio(Dev Mode) and not when its installed as an application.

I Use a "User  Control" into the ActiveX Control which is not working as expected. Then I Also tried loading the user control inside a Windows Form it is working properly.(from an installed application).

What am i missing here Some Info. will be really helpful.

P.S:
Here i Use Wix to build the application setup.
I disabled all the other addins and it is still not working.

Thanks in advance.
Nabil