Book a Demo

Author Topic: Adding an HTML doc with Repository.AddTab  (Read 5863 times)

Mhatch

  • EA User
  • **
  • Posts: 27
  • Karma: +0/-0
    • View Profile
Adding an HTML doc with Repository.AddTab
« on: November 28, 2013, 06:49:50 am »
I'm trying to create a new view (tab) of a web page using Repository.AddTab, but the following method doesn't work (returns null):

var IE = Repository.AddTab("HTML Control", "InternetExplorer.Application");

I know that you can create Hyperlink objects that open web pages in the Sparx client, but I want to automate further and do not know how to get access to the browser object from script if I use this method.  

I have tried to find alternate ProgID's for web browser controls, but none seem to work.

Using this code successfully launches IE as a separate app, but I want it contained within the Sparx client:

var IE = new ActiveXObject("InternetExplorer.Application");

Any thoughts?
« Last Edit: November 28, 2013, 06:50:23 am by mike.hatch »

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Adding an HTML doc with Repository.AddTab
« Reply #1 on: November 28, 2013, 03:24:10 pm »
At a guess, that object can only be created as an external application.

http://msdn.microsoft.com/en-us/library/aa752127(VS.85).aspx should give you a hint on how to create an embedded version.

Mhatch

  • EA User
  • **
  • Posts: 27
  • Karma: +0/-0
    • View Profile
Re: Adding an HTML doc with Repository.AddTab
« Reply #2 on: December 03, 2013, 03:30:23 am »
Thanks for the response Simon.  Indeed, I tried several different ProgIds, all with similar results.

var IE = Repository.AddTab("HTML Control", "Shell.Explorer.2");
var IE = Repository.AddTab("HTML Control", "SHDocVw.IWebBrowser2");
var IE = Repository.AddTab("HTML Control", "IWebBrowser2");

It appears that 'IWebBrowser2' is an interface on the object and does not have it's own root ProgID? The Repository.AddTab method doesn't have an overload that creates an object against a nested interface, which is what the code sample of the article you linked shows:

IWebBrowser2*    pBrowser2;

   CoCreateInstance(CLSID_InternetExplorer, NULL, CLSCTX_LOCAL_SERVER,
                       IID_IWebBrowser2, (void**)&pBrowser2);

            
Any other ideas?

Thanks!
-Mike

Mhatch

  • EA User
  • **
  • Posts: 27
  • Karma: +0/-0
    • View Profile
Re: Adding an HTML doc with Repository.AddTab
« Reply #3 on: December 06, 2013, 10:24:20 am »
Any other ideas from the community on this?  Anyone else successfully using Repository.AddTab method to add/browse HTML pages with a browser?  Any user control?

Thanks!
-Mike

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Adding an HTML doc with Repository.AddTab
« Reply #4 on: December 06, 2013, 06:07:58 pm »
Mike,

I'm guessing AddTab works the same way as AddWindow right?
In that case I would start by creating a user control of my own in a standalone application.
The add the embedded browser of your choice to your user control.
Once all that works you just need to add your user control to EA using AddTab (or AddWindow).
See https://github.com/GeertBellekens/Enterprise-Architect-Add-in-Framework/tree/master/MyAddin for an example of a user control added to EA using AddWindow.

Geert