Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

showing form interupt user interaction

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
GVDB
430 Views, 3 Replies

showing form interupt user interaction

Hi,

 

I'm writing an automatic ballooning program from out the partlist inside a vb.net 2010 addin. (INV 2013)

I'm nearly there but have just one problem.

When starting the routine a form with only a label (message) in it is showed. Just to inform the user!

Then the ballooning command is started. The user can cancel this piece of ballooning by clicking ESC.

 

But the problem is that the user first must click anywhere in the screen to activate inventor before he can click ESC

Why is that? Has the form still have the focus? How can I solve this problem.

 

Geert

 

Here is a snipset of my code:

  

Public Sub AutomaticBallooning() 

Try

Dim frmPartlistRowMessage AsNewfrmMessage

Dim strPartlistRowText AsString = "TEST  -> press [ESC] to cancel ballooning and for other options!"

frmPartlistRowMessage.Show()

frmPartlistRowMessage.labMessage.Text = strPartlistRowText

modGeneral.AlwaysOnTop(frmPartlistRowMessage, True)

           

'call balloon commando and wait till it's done

Dim oControlDef As Inventor.ControlDefinition

oControlDef = m_inventorApplication.CommandManager.ControlDefinitions.Item(

"DrawingBalloonCmd")

           

Try

      oControlDef.Execute()

Catch ex AsException

EndTry

           

DoWhile m_inventorApplication.CommandManager.ActiveCommand = "DrawingBalloonCmd"Or m_inventorApplication.CommandManager.ActiveCommand = "InteractionEvents"

                m_inventorApplication.UserInterfaceManager.DoEvents()

Loop

       

Catch ex AsException

EndTry

end sub

 

PublicSub AlwaysOnTop(ByVal frmobject As System.Windows.Forms.Form, ByRef Status AsBoolean)

Try

If Status = TrueThen

       frmobject.TopMost = True

Else

        frmobject.TopMost = False

EndIf

       

Catch ex AsException

EndTry

EndSub

 

3 REPLIES 3
Message 2 of 4
nagwani
in reply to: GVDB

Hi There,

 

Setting the owner of form as Inventor frame window should solve this problem.

 

frmPartlistRowMessage.Show(New WindowWrapper(m_inventorApplicationMainFrameHWND))

 

The WindowWrapper class is given below.

 

Public Class WindowWrapper
    Implements System.Windows.Forms.IWin32Window
    Public Sub New(ByVal handle As IntPtr)
        _hwnd = handle
    End Sub
    Public ReadOnly Property Handle() As IntPtr _
    Implements System.Windows.Forms.IWin32Window.Handle
        Get
            Return _hwnd
        End Get
    End Property
    Private _hwnd As IntPtr
End Class

 

-Ishwar

Message 3 of 4
GVDB
in reply to: nagwani

Hi Ishwar,

 

thanks for your reply.

I already had tried setting owner with this code with no result:

Dim owner AsNew System.Windows.Forms.NativeWindow

owner.AssignHandle(m_inventorApplication.MainFrameHWND)

oFormMessage.Show(owner)

 

I tried your way with the WindowWrapper class but unfortunately also with no result!

It seems that showing a form inactivates Inventor till user clicks into the screen.

 

other suggestions?

 

Geert

 

 

Message 4 of 4
GVDB
in reply to: GVDB

Sometimes the solution is right in front of you but you don't see it.

 

Just put -> AppActivate(m_inventorApplication.Caption) to it and there you go.

 

Problem solved!

 

Geert

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report