13 Replies Latest reply on Mar 27, 2013 2:46 PM by DavidMFairchild

    ProcessBook .NET Add-In Custom Toolbar Icons


      Hello - I have a couple questions about how to implement custom icons for ProcessBook .NET Add-In Toolbar buttons


      1) Is it possible to include the images in a .dll/resouce and reference them in a manner like this:
      http://www.mztools.com/articles/2005/MZ2005007.aspx    or


      2) Is it possible to use images that are partially transparent?


      The code below works for an image in some folder but does not support transparency (bitmap only it seems, and the image isn't hidden in a .dll, etc)


      e As PBCommandBarButton = CType(m_pbControl, PBObjLib.PBCommandBarButton)
      e.Style = pbButtonStyle.pbButtonIcon


      I've been trying to figure out if using "e.LoadFaceResource(nAppInstance As Integer, nBmpResourceId As Integer)" is the way to go but I don't know what the correct values are for the arguments.



        • Re: ProcessBook .NET Add-In Custom Toolbar Icons

          still under research, I am checking with the PB developer.



            • Re: ProcessBook .NET Add-In Custom Toolbar Icons

              I don't recall the details of the bitmap loading from resource files (it is not a widely used feature). I'm thinking it would be an uphill battle to make work if you're not writing your add-in in VC++.


              However, I can help with transparent icon colors. Magenta (Red: 255, Green:0, Blue:255) will be renendered transparent on any images loaded through automation (at least those loaded from files). If you manage to get icons loaded from resources it may be that color OR gray, (Red:128, Green:128, Blue:128).


              We still may want to check with a PB developer to confirm this...



                • Re: ProcessBook .NET Add-In Custom Toolbar Icons



                    Magenta does work for transparency - thanks!  I am still very interested in how I could package these images in my .NET Add-In project so they aren't available to the user.



                    • Re: ProcessBook .NET Add-In Custom Toolbar Icons

                      Like Mike said, it is a bit of an uphill battle, but it can be done. The call LoadFaceResource takes in the DLL instance and the WIN32 resource ID. The major problem is that .NET handles resources differently then WIN32 applications did.


                      The basic principle is to create a WIN32 res file, compile it into your addin, and then add it to the toolbar.


                      Step 1 – Create the res file
                      1.    In VS, create a new file, Category = General and Template = Native Resource Template
                      2.    Import your BMPs into this file.
                      3.    Save as .RES file


                      Step 2 – Compiling into Addin (from http://msdn.microsoft.com/en-us/library/8f2f5x2e.aspx)
                      1.    Open the project's Properties page.
                      2.    Click the Application property page.
                      3.    Click on the Resource File button and choose a file by using the combo box.


                      Step 3 – Creating the toolbar
                      /*PBCommandBarButton*/ m_pbControl = (PBObjLib.PBCommandBarButton)pbControls.Add((Object)PBObjLib.pbControlType.pbControlButton, 1, null, null, false);
                      m_pbControl.Style = pbButtonStyle.pbButtonIcon;
                      int nAppInstance = (int)Marshal.GetHINSTANCE(this.GetType().Module);
                      int nBmpResourceId = 101;

                      m_pbControl.LoadFaceResource(nAppInstance, nBmpResourceId);




                      To get the nBmpResourceId, I just reopened the .RES file in Visual Studio.

                      I hope this helps.