HowTo: Add a ButtonPopup to Inventor GUI?

HowTo: Add a ButtonPopup to Inventor GUI?

Anonymous
Not applicable
946 Views
3 Replies
Message 1 of 4

HowTo: Add a ButtonPopup to Inventor GUI?

Anonymous
Not applicable
Hello,

I want expand the GUI from a Ribbon with one Button (see below) to a ribbon
with a ButtonPopup for two Buttons. Has someone an example or can expand my
code below? Environment: Inventor 2010 AddIn, with VB.Net 2005, 32 Bit
Many thanks in advance.

doc snyder


Private Sub AddExportButton(ByVal bFirstTime As Boolean)
' Create the button definition.
Dim controlDefs As ControlDefinitions
controlDefs = m_InvApp.CommandManager.ControlDefinitions

' Convert the Image to a Picture.
Dim picSmall As stdole.IPictureDisp, picBig As stdole.IPictureDisp
picSmall =
Microsoft.VisualBasic.Compatibility.VB6.ImageToIPictureDisp(My.Resources.Pic_Export_Small)
picBig =
Microsoft.VisualBasic.Compatibility.VB6.ImageToIPictureDisp(My.Resources.Pic_Export_Big)

m_oButtonDef = controlDefs.AddButtonDefinition( _
"Measure Program Generator", _
"ExportMeasureAddIn", _
CommandTypesEnum.kQueryOnlyCmdType, _
m_ClientID, _
Measure Program Export", _
Measure Program Generator", _
picSmall, picBig)

If bFirstTime Then
' Create a new command bar (toolbar) and make it visible.
Dim commandBars As CommandBars
commandBars = m_InvApp.UserInterfaceManager.CommandBars
Dim commandBar As CommandBar
commandBar = commandBars.Add("Measure Program", "ExportMeasureAddIn",
, m_ClientID)
commandBar.Visible = True

' Add the control to the command bar.
commandBar.Controls.AddButton(m_oButtonDef)
End If
End Sub
0 Likes
947 Views
3 Replies
Replies (3)
Message 2 of 4

Ralf_Krieg
Advisor
Advisor
Hello

Simplified, create a second CommandBar of Type SplitButton. Add your first button to the SplitButton and then add the SplitButton to your CommandBar. Edited by: krieg on Feb 26, 2010 5:41 PM

R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes
Message 3 of 4

Ralf_Krieg
Advisor
Advisor
Could not test it, but try this.

Private Sub AddExportButton(ByVal bFirstTime As Boolean)
' Create the button definition.
Dim controlDefs As ControlDefinitions
controlDefs = m_InvApp.CommandManager.ControlDefinitions

' Convert the Image to a Picture.
Dim picSmall As stdole.IPictureDisp, picBig As stdole.IPictureDisp
picSmall =
Microsoft.VisualBasic.Compatibility.VB6.ImageToIPictureDisp(My.Resources.Pic_Export_Small)
picBig =
Microsoft.VisualBasic.Compatibility.VB6.ImageToIPictureDisp(My.Resources.Pic_Export_Big)

m_oButtonDef = controlDefs.AddButtonDefinition( _
"Measure Program Generator", _
"ExportMeasureAddIn", _
CommandTypesEnum.kQueryOnlyCmdType, _
m_ClientID, _
Measure Program Export", _
Measure Program Generator", _
picSmall, picBig)

If bFirstTime Then
' Create a new command bar (toolbar) and make it visible.
Dim commandBars As CommandBars
commandBars = m_InvApp.UserInterfaceManager.CommandBars
Dim commandBar As CommandBar
commandBar = commandBars.Add("Measure Program", "ExportMeasureAddIn",
, m_ClientID)
commandBar.Visible = True

'Create a command bar of a splitbutton type for a flyout.
Dim oSplitBtnCmdBar As CommandBar
Set oSplitBtnCmdBar = objInventorApp.UserInterfaceManager.CommandBars.Add("SplitButtonname", "ExportMeasureAddIn", kSplitButtonMRUCommandBar, m_ClientID)

' Add two buttons to the splitbutton command bar.
oSplitBtnCmdBar.Controls.AddButton m_oButtonDef


' add splitbutton to commandbar
Call oCommandBarSlot.Controls.AddSplitButtonMRU(oSplitBtnCmdBar, "SplitButtonname")

' Add the control to the command bar.
commandBar.Controls.AddButton(m_oButtonDef)
End If
End Sub Edited by: krieg on Feb 26, 2010 3:42 PM

R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes
Message 4 of 4

Anonymous
Not applicable
Hello krieg,

thank you for the example. I instead have used a workaround by inserting two
simple buttons. Your given example fails, se below. In addition, I've tried
to use the AddButtonPopup function, which fails also. Nothing to do! The
user accepts the simple solution.

doc snyder


I get a exception at line
oSplitBtnCmdBar =
m_InvApp.UserInterfaceManager.CommandBars.Add("SplitButtonname",
"ExportMeasureAddIn", _' CommandBarTypeEnum.kSplitButtonMRUCommandBar,
m_ClientID)

"System.Runtime.InteropServices.COMException (0x80004005): Unbekannter
Fehler (Ausnahme von HRESULT: 0x80004005 (E_FAIL))
bei System.RuntimeType.ForwardCallToInvokeMember(String memberName,
BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData&
msgData)
bei Inventor.CommandBars.Add(String DisplayName, String InternalName,
CommandBarTypeEnum CommandBarType, Object ClientId)
bei ExportMeasureAddin.CMeasureExporter.AddExportButtonsAsPopup(Boolean
bfirstTime) in

--------------------------
A try with following code fails also:

Dim commandBars As CommandBars
commandBars = m_InvApp.UserInterfaceManager.CommandBars
Dim commandBar As CommandBar
commandBar = commandBars.Add("Measure Program", "ExportMeasureAddIn",
CommandBarTypeEnum.kButtonPopupCommandBar, m_ClientID)
commandBar.Visible = True

m_oCmdBarCtrl = oCmdBarCtrls.AddButtonPopup(commandBar, m_oButtonDef)
m_obuttonCtl = oCmdBarCtrls.AddButton(m_oButtonDef)
m_oBtnParamCtl = oCmdBarCtrls.AddButton(m_oBtnParamDlgDef)



schrieb im Newsbeitrag news:6345000@discussion.autodesk.com...
Hello

Simplified, create a second CommandBar of Type SplitButton. Add your first
button to the SplitButton and then add the SplitButton to your CommandBar.

Edited by: krieg on Feb 26, 2010 5:41 PM
0 Likes