Author Topic: Finding the visibility of an Addin Window  (Read 2110 times)

Ian Mitchell

  • EA User
  • **
  • Posts: 506
  • Karma: +22/-4
  • The eaDocX and Model Expert guy
    • View Profile
Finding the visibility of an Addin Window
« on: May 16, 2023, 06:46:33 pm »
Using the Addin Windows approach is proving to be a good solution to providing simple bits of UI, which a user can move around and dock etc.

I've come across an interesting challenge.

If a user has a particular Addin Window opened, and it's contents depend on what the user has got selected, then the polite behaviour is to handle the EA_OnContextItemChanged event from EA, and change the contents of the already opened Addin Window to show what's needed for the new element.
Exactly like the EA 'Properties' pane.

This works just fine.

But now the user closes the Addin Window, using the 'X' top right.
What seems to happen is that the Addin Window is still alive, but just not visible. @Sparx - can you confirm this?
The behaviour which a user would expect now is different. They closed the Addin Window, so when they select a different object, nothing interesting should happen. Because they closed the Addin Window. Just the same bevaviour as, for example, the EA Properties pane. If I close the Peroerties pane, then switching elements doesn't make it suddenly pop-up if I previously closed it.

But how to detect that the user previously closed the Addin Window? It seems to be still alive as a object, and the act of 'closing' it in EA doesn't seem to fire any windows events, like 'Dispose' or 'Handle_Destroyed', maybe because EA hasn't destroyed anything. Maybe EA just made it invisible. But how to find this out?

Has anyone else come across this issue? How to detect if an Addin Window has been opened, but then closed by the user.
Thanks
Ian Mitchell, Designer, eaDocX


www.eaDocX.com
www.theartfulmodeller.com

Ian Mitchell

  • EA User
  • **
  • Posts: 506
  • Karma: +22/-4
  • The eaDocX and Model Expert guy
    • View Profile
Re: Finding the visibility of an Addin Window
« Reply #1 on: May 16, 2023, 08:22:58 pm »
So using my new best friend - ChatGPT - after a few iterations of 'no that didn't work, try something else', it came up with :

    Private Declare Function IsWindowVisible Lib "user32.dll" (ByVal hWnd As IntPtr) As Boolean

    Friend Function hasBeenClosedByEA() As Boolean
        Return Not IsWindowVisible(Me.Handle)

    End Function
So if I look into the cloudy depths of Windows, this 'IsWindowVisible' returns the true visibility status of the window.
@Sparx  please can we have a new API call to do this in a more friendly way?
Ian Mitchell, Designer, eaDocX


www.eaDocX.com
www.theartfulmodeller.com