Set the tab icon for a custom defined taskpane view

17 Oct

From the SolidWorks API document, the icon for a user-defined custom taskpane view should be:

“The bitmap should be 16 colors and 16 x 18 (width x height) pixels. Any portions of the bitmap that are white (RGB 255,255,255) will be transparent.” The 16 colors bitmap is usually too ugly to accept. I therefore tried to use 32-bit BMP with transparencies, and also, I used 16×16 size bmp, which can be found here and there on the web. The good news is, it worked!

The bad news is that it worked locally, and when I packaged the project for deployment on the user’s machine, the icon I chose does not show up. I guess this might be due to the location of the bmp is not found. So I modified the code to make to be an abosolute path:

//This works only on local machine, when setup project is packaged, this no longer works
//pane = SwApp.CreateTaskpaneView2(“../VoiceCAD.bmp”, FormTitle);

//This works both on local machine and the deployed machine
string MainPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
DirectoryInfo MainDir = new DirectoryInfo(MainPath); // “file:///W|/bin
string MainFolder = MainDir.Parent.FullName; //”\\”
string IconFilePath = Path.Combine(MainFolder, “VoiceCAD.bmp”);

pane = SwApp.CreateTaskpaneView2(IconFilePath, FormTitle);

Now, it works, really works.


Posted by on October 17, 2008 in CAD


4 responses to “Set the tab icon for a custom defined taskpane view

  1. tovelu

    January 23, 2009 at 7:09 pm


    i am working as a solid works api engineer in a pvt company, please explain me, how can i add my application in solidworks task pane like you added (VoiceCAD). Please give me any sample document.

    Thanks in Advance

  2. xinyustudio

    January 29, 2009 at 5:40 pm

    It is a long story, and involves .net InterOp, windows handle mapping etc.

  3. geodas

    February 13, 2010 at 4:37 am

    Is it possible to get some programcode from you, to add applications in teh SolidWorks task pane. I have wrote a program in VB.NET

    Thanks in advance


  4. tsettergren

    November 19, 2011 at 9:35 pm

    xinyustudio, I created a swaddin taskpane application in and specified an icon of the proper size and color depth, but it doesn’t show the icon. Do you know why this would be? I even tried a very simple location for the icon just to see if it would show up at all for me like the following:
    mTaskpaneView = mSWApplication.CreateTaskpaneView2(“C:\taskPaneIcon.bmp”, “swUtilities”)

    Any help would be appreciated.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: