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

    ProcessBook .NET Add-In Custom Toolbar Icons

    helgesonc

      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
      http://msdn.microsoft.com/en-us/library/aa290364%28VS.71%29.aspx

       

      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)

       

      Dim
      e As PBCommandBarButton = CType(m_pbControl, PBObjLib.PBCommandBarButton)
      e.Style = pbButtonStyle.pbButtonIcon
      e.LoadFace("C:\<path>\<image>.bmp")

       

      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.

       

      Thanks!

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

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

           

          Regards,

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

              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
                  helgesonc

                  Michael,

                   

                    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.

                   

                  Thanks!

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

                      Caleb,
                      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.
                      Jason