5 Replies Latest reply on Mar 14, 2013 2:12 PM by DavidMFairchild



      I am trying to load a bit map for the button face from a Resource imbedded in a Processbook Add-in using VB6.


      I had no problem loading the bit maps into the resource, but I don't know how to get the AppInstanceID required to use the LoadFaceResource funcion.


      Just to reiterate, this is VB6 not VB.Net.


      Can anyone tell me how to get this?







        • Re: PBCommandBarButton.LoadFaceResource

          A waring - I haven't used this before myself!  That said, have you tried the hWnd of the application? 



          Option Explicit
          Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
          Sub test()
          Dim hWnd As Long
          hWnd = FindWindow(vbNullString, Application.Caption)
          Debug.Print hWnd
          End Sub


            • Re: PBCommandBarButton.LoadFaceResource

              From my past experience,  LoadFace (filename) should be used in PI ProcessBook instead of LoadFaceResource, especially if the add-in is written in VB6.


              Hope that helps.

                • Re: PBCommandBarButton.LoadFaceResource

                  Well, I wound up converting the toolbar to C#.Net.  Now I am trying to figure out how to set the PBCommandBarButton Face from a resouce instead of a file in C#.


                  Has anyone ever done this?  I really don't want to have to include 8 bit map files with my DLL.


                  I'm using VS 2008 I have tried embedding the images, but currently they are not.  But they are all part of the .resx file.  Either way I cannot find what ProcessBook wants for an image.

                    • Re: PBCommandBarButton.LoadFaceResource

                      @David: I invite you to take a look at this thread where it was discussed the same thing.

                        • Re: PBCommandBarButton.LoadFaceResource

                          Thanks Mathieu,


                          I was eventually able to resolve the issue.  I found this link more useful.  One of the problems though is in the differences between VS2005 and VS2008.  Particularly regarding the handling of embedded resources.  In VS2008 Microsoft wants you to create an xml resource file (.resx) and access the files using <namespace>.<filename>.<resourcename>.  But LoadFaceResource doesn't support that.  The older C style embedded resources that were supported in VS2005 are supported by LoadFaceResource. 


                          I did stumble on a way to create the .res file with VS2008.  It was easy enough, but I haven't been able to find the instructions since.  Next you have to get the resource file included in the project.  The way I did this was to use the properties page of the project on the Application Tab.  At the bottom of the page there is a place to provide the pathof a resource file.


                          (int)Marshal.GetHINSTANCE(this.GetType().Module); did give me the correct AppInstance.  FindWindow did not work.


                          You can verify that the resource is included in your add-in by opening the .dll with Visual Studio.  If the resources were embedded, they  will show up there.  Other information from your post is also valuable such as the requirement for a bitmap image, of 256 bits or less and larger than 16 x 16.  But these were not my issue.