• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Autodesk Inventor Customization

    Reply
    Mentor
    Posts: 215
    Registered: ‎01-16-2006
    Accepted Solution

    showing form interupt user interaction

    70 Views, 3 Replies
    01-28-2013 01:37 AM

    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

     

    Please use plain text.
    Employee
    nagwani
    Posts: 33
    Registered: ‎11-17-2011

    Re: showing form interupt user interaction

    01-28-2013 09:49 PM 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

    Please use plain text.
    Mentor
    Posts: 215
    Registered: ‎01-16-2006

    Re: showing form interupt user interaction

    01-28-2013 11:39 PM 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

     

     

    Please use plain text.
    Mentor
    Posts: 215
    Registered: ‎01-16-2006

    Re: showing form interupt user interaction

    01-29-2013 02:14 AM 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

    Please use plain text.