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
Solved! Go to Solution.
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
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
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.