First of all this is done in a VB.NET add-in (Visual Basic 2010 Express).
This is the code in the activate section of the add-in (where the button is declared and put in a ribbon).
Dim oControlDefinitions As ControlDefinitions
Dim oUIManager As UserInterfaceManager
oControlDefinitions = m_inventorApplication.CommandManager.ControlDefinitions
oUIManager = m_inventorApplication.UserInterfaceManager
oTestButton = oControlDefinitions.AddButtonDefinition("Test Button", "oTestButton", CommandTypesEnum.kQueryOnlyCmdType, sClientID)
oTestButton.LargeIcon = clsPictureDispConverter.ToIPictureDisp(New System.Drawing.Icon(My.Resources.Compact_Disk, 32, 32))
If firstTime = True Then
'===Ribbon section===
Dim oRibbon As Ribbon
Dim oTestRibbon As RibbonTab
Dim oTestPanel As RibbonPanel
For Each oRibbon In oUIManager.Ribbons
' Create a new tab
oTestRibbon = oRibbon.RibbonTabs.Add("Test Ribbon", "oTestRibbon", sClientID)
' Create a new panel within the tab
oTestPanel = oTestRibbon.RibbonPanels.Add("Test Panel", "oTestPanel", sClientID)
' Create a control within the panel
Call oTestPanel.CommandControls.AddButton(oTestButton, True)
Next oRibbon
End If
This is the code in the oTestButton_OnExecute event.
oTestButton.LargeIcon = clsPictureDispConverter.ToIPictureDisp(New System.Drawing.Icon(My.Resources.DVD_Disk, 32, 32))
The clsPictureDispConverter is a custom class that contains a function for converting the icon to an IPictureDisp. See http://modthemachine.typepad.com/my_weblog/2012/02/bitmaps-without-vb6-icontoipicture.html for more information.
I hope you can understand how this works now.
Best regards,
Daniël