Book a Demo

Author Topic: Focus foreground when using DLL  (Read 10035 times)

aloeffen

  • EA User
  • **
  • Posts: 37
  • Karma: +0/-0
    • View Profile
Focus foreground when using DLL
« on: January 08, 2016, 02:26:09 am »
Sparx EA keeps pressing itself to the foreground (without any actual screen interaction) when I start a EA process using the DLL/java API.  For example, exporting to XMI or generating a report "in the background" inhibits any further interaction with the Windows OS as EA presses itself to the foreground.

How can I stop this behavior?

This has been the case in EA 10 as well as in EA12.

arjan
 

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Focus foreground when using DLL
« Reply #1 on: January 08, 2016, 03:06:02 am »
Hi Arjan,

There's nothing in the EA API that allows you to minimize the window, but you can hide it using Project::ShowWindow() or Repository::ShowWindow(). This is normal practice when opening an EA project from the API.

As for EA inhibiting other interactions, that's only if its window is maximized. You can minimize it using the task manager.

For more fine-tuned control, you could hack the registry. EA has an option which controls whether it starts maximized or remembers the window size from last time, so you could modify the corresponding registry entries before you create your Repository. Or you could get hold of the window handle after it's been created and use the Windows API to minimize the EA window.

But hiding the window is the simple solution.

Cheers,


/Uffe
My theories are always correct, just apply them to the right reality.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Focus foreground when using DLL
« Reply #2 on: January 08, 2016, 05:07:19 am »
You can also try setting Repository.EnableUIUpdates = false

Geert

aloeffen

  • EA User
  • **
  • Posts: 37
  • Karma: +0/-0
    • View Profile
Re: Focus foreground when using DLL
« Reply #3 on: January 08, 2016, 08:10:07 am »
I specified:

project.ShowWindow(0);
repo.ShowWindow(0);
repo.SetEnableUIUpdates(false);

This doesn't help. It doesn't affect behavior. I do not know how to interpret:

ShowWindow (long Show)

as the long Show is not explained anywhere (or at least I cannot find its definition at or near http://www.sparxsystems.com/enterprise_architect_user_guide/9.3/automation/project_2.html).

Can you help?

arjan

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Focus foreground when using DLL
« Reply #4 on: January 08, 2016, 09:28:17 am »
Using the glorious new help, "showwindow" shows no results at all.
Quote
Your search for showwindow did not return any matches (2574 documents were searched):

q.

RoyC

  • EA Administrator
  • EA Practitioner
  • *****
  • Posts: 1297
  • Karma: +21/-4
  • Read The Help!
    • View Profile
Re: Focus foreground when using DLL
« Reply #5 on: January 08, 2016, 11:41:51 am »
But it is there, in the Project Class topic, in the Project Methods table.

ShowWindow (long Show)
protected abstract: Void
Notes: Shows or hides the Enterprise Architect User Interface.
Parameters:
     Show: Long

It's also in the Repository Class topic, in the Repository Methods table. 

I could not find it using the web search, but I did find it using the 'Help | Search Help' menu option within EA.
Best Regards, Roy

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Focus foreground when using DLL
« Reply #6 on: January 08, 2016, 07:17:23 pm »
I do not know how to interpret:

ShowWindow (long Show)

as the long Show is not explained anywhere (or at least I cannot find its definition at or near http://www.sparxsystems.com/enterprise_architect_user_guide/9.3/automation/project_2.html).
It's 0 to hide, non-zero to show. The one in Repository and the one in Project are equivalent, there's no need to call both.

I wouldn't expect Repository.EnableUIUpdates to affect the behaviour when generating reports or exporting XMI. It's there mainly to stop EA from aggressively refreshing the project browser when you make bulk changes to your models, which exports and reports don't do -- they just read the models.

If it doesn't work you should probably look at how you're initializing your connection to the repository, make sure everything is done in the right order.

/Uffe
My theories are always correct, just apply them to the right reality.

aloeffen

  • EA User
  • **
  • Posts: 37
  • Karma: +0/-0
    • View Profile
Re: Focus foreground when using DLL
« Reply #7 on: January 08, 2016, 07:53:54 pm »
You state:
Quote
If it doesn't work you should probably look at how you're initializing your connection to the repository, make sure everything is done in the right order.
Now I am using:

repo = new Repository();
repo.ShowWindow(0);
repo.SetEnableUIUpdates(false);
project = repo.GetProjectInterface();
repo.OpenFile(sourcePath);
project.ExportPackageXMIEx(project.GUIDtoXML(rootPackageGUID), EnumXMIType.xmiEADefault, 1, -1, 1,0, resultPath, 0);

Do you see anything out of the ordinary?

Thanks,
arjan