Reply

How to add bitmap on buttons of SE ribbon in C#?

[ Edited ]

Hi All,

 

I am developing SE add-in in C#.

I could add button on SE ribbon but unable to see bitmap on these buttons. See my code below...

 

public void OnConnectToEnvironment(string EnvCatID, object pEnvironmentDispatch, bool bFirstTime)
{
    try
    {
        // Allocate room for required arrays for CommandBars.
        Array commandNames = Array.CreateInstance(typeof(String), 2);
        Array commandIDs = Array.CreateInstance(typeof(int), 2);

        // Populate arrays.
        commandNames.SetValue("cmdButton1\n\nButton1 Description\nButton1", 0);
        commandNames.SetValue("cmdButton2\n\nButton2 Description\nButton2", 1);
      
        commandIDs.SetValue(101, 0);
        commandIDs.SetValue(102, 1);

        // Call SetAddInInfo              
        addin.SetAddInInfo(
            Marshal.GetHINSTANCE(this.GetType().Module).ToInt32(),
            EnvCatID,
            "Buttons",
            101,
            102,
            -1,
            -1,
            2,
            ref commandNames,
            ref commandIDs);

        // Check for 1st time.
        if (bFirstTime)
        {
            CommandBarButton button1 = addin.AddCommandBarButton(EnvCatID,  "Buttons", 101);
            button1.Style = SolidEdgeFramework.SeButtonStyle.seButtonIconAndCaption;

            CommandBarButton  button2 = addin.AddCommandBarButton(EnvCatID,  "Buttons", 102);
            button2.Style = SolidEdgeFramework.SeButtonStyle.seButtonIconAndCaption;                 
        }
    }
    catch (System.Exception e)
    {
         MessageBox.Show(e.Message);
    }
}

 

For this purpose, I referred VB.NET add-in example present in SDK folder (Program Files\Solid Edge ST4\SDK\Samples\Addins\VB .NET).

But when I run this VB.NET add-in, I couldn't see bitmap images on buttons!

 

I have followed following steps to give bitmap IDs as argument to 'SetAddInInfo' API:

1. Add two bitmap files in Add.res file

a) 32x16: It contains two 16x16 images for two buttons placed side by side in single bitmap (ID:101)

b) 48x24: It contains two 24x24 images for two buttons placed side by side in single bitmap (ID:102)

2. Give the IDs of these bitmaps as argument(4th an 5th argument) to 'SetAddInInfo' API.

 

Am I missing any step?

 

Please guide me to solve this problem.

 

Thanks in advance.

 

-Amit

 

Posted by: Amit Wadekar
Post date: 10/12/2012 8:23:00 AM

1 REPLY

How to add bitmap on buttons of SE ribbon in C#?

[ Edited ]

Hi Jason,

 

Can you help me to solve this problem?

Thank you,

 

-Amit

 

Posted by: Amit Wadekar
Post date: 10/19/2012 1:07:04 AM