Results 1 to 10 of 10

Thread: [RESOLVED] Integrate two different resource files

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2016
    Location
    Italy
    Posts
    235

    Resolved [RESOLVED] Integrate two different resource files

    In one of my projects I use a file resource; if I want to implement Ribbon 2007 (http://www.planet-source-code.com/vb...66951&lngWId=1) can I integrate the resource file of this project with the resource file of my project? is there an editor that allows it?

  2. #2
    Hyperactive Member
    Join Date
    Aug 2017
    Posts
    380

    Re: Integrate two different resource files

    Resource Hacker can add resources from a .RES file to another .RES file.



  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2016
    Location
    Italy
    Posts
    235

    Re: Integrate two different resource files

    It doesn't work; apparently joins the two files but loading project vb6 IDE shows: "It is not a valid resource file".

  4. #4
    Hyperactive Member
    Join Date
    Aug 2017
    Posts
    380

    Re: Integrate two different resource files

    Can you describe what you did step-by-step? Can you attach the .RES file that you wish to extend (I'll get the other one from the link you provided)? If it's bigger than the forum's max allowed file size for .RES files (97.7 KB), then ZIP it up or compress it with 7Zip.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Nov 2016
    Location
    Italy
    Posts
    235

    Re: Integrate two different resource files

    I opened the file "Themes.res" with Resource Hacker, then in "Action" I selected the file "FCP.res" with "Add from a resource file" and finally saved the new file ...

    https://drive.google.com/file/d/1Vcy...ew?usp=sharing

  6. #6
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Integrate two different resource files

    You can do this yourself if you want, if both files are .res format...

    Change the file path/names below. The code will copy one res file then append the other, stripping off the 1st 32 bytes from the appended one. That will properly join the two. The code also ensures DWord alignment is maintained which is also a requirement. This routine does not resolve duplicate IDs/Names
    Code:
    Private Sub Command1_Click()
    
        Const sFile1 As String = "C:\Res1.res"
        Const sFile2 As String = "C:\Res2.res"
        Const sCombined As String = "C:\Res3.res"
        
        Dim a() As Byte, lSize As Long, lOffset As Long
        
        FileCopy sFile1, sCombined  ' copy source#1 to combined
        DoEvents
        Open sCombined For Binary As #1
        lSize = FileLen(sCombined)
        
        lOffset = 32                ' strip 32 bybtes from file to be joined
        ' ensure DWord aligned, borrowing from 32 bytes above
        If (lSize And 3) <> 0 Then
            lOffset = lOffset - (4 - (lSize And 3))
        End If
        
        Open sFile2 For Binary As #2 ' get bytes from source#2
        ReDim a(0 To LOF(2) - lOffset - 1)
        Get #2, lOffset + 1, a()
        Close #2
        
        Put #1, lSize + 1, a()      ' append bytes from source#2 to combined
        Close #1
        
        MsgBox "Done"
    
    End Sub
    FYI. Regarding your error when you tried to merge them before, do both res files load into VB separately? If so, do they share any resource item names, i.e., do they both have items in the same group (bitmap, icon, "CUSTOM", etc) with the same ID (101, 102, etc)? If so, you may want to open each in separate VB instances, locate the duplicates and rename one of them. Then save the changes and try merging again.

    Edited: Another FYI... If IDs are duplicated, the above merge will work, but when the combined res file is brought into VB, only one of each duplicate is displayed in its resource editor. The 2nd one is silently skipped and likely removed if that res file is later changed/saved. So, rename duplicates first.
    Last edited by LaVolpe; Jul 4th, 2020 at 11:50 AM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Nov 2016
    Location
    Italy
    Posts
    235

    Re: Integrate two different resource files

    Sorry but I was busy.
    The resource file is too large for vbforums, you can download it from the link. The groups are different (Custom, Black, Blue, Silver, Strings). Obviously the numbers inside the individual groups start with 101

  8. #8
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Integrate two different resource files

    Don't have 7z installed. Did you try the sample code I provided?
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  9. #9
    Hyperactive Member
    Join Date
    Aug 2017
    Posts
    380

    Re: Integrate two different resource files

    OK, try this if you're still interested in using Resource Hacker:

    1. Make a temporary folder in a location of your choice.
    2. Open FCP.RES with Resource Hacker.
    3. Click Action >> Save ALL Resources to an RC file ...
    4. Save the .RC file in the temp folder you've just created. The binary resources in the .RES file will be saved there as well.
    5. Open Themes.res using the same Resource Hacker instance (or close it and start a new instance if you prefer).
    6. Repeat steps 3-4 for Themes.res. Close Resource Hacker afterwards.
    7. Now, open the FCP.rc and Themes.rc files that you just saved in your favorite text editor and combine them (either copy everything in Themes.rc to FCP.rc or vice versa; it doesn't matter). Make sure to insert newline(s) between the 2 resource scripts to avoid possible syntax errors.
    8. Insert these constant definitions at the top of the script:
      Code:
      #define LANG_NEUTRAL    0x00
      #define SUBLANG_NEUTRAL 0x00
      #define LANG_ITALIAN    0x10
      #define SUBLANG_ITALIAN 0x01
      Again, insert newline(s) to separate the #defines from the other lines.
    9. Save the modified resource script afterwards and close it.
    10. Compile the .RC file using VB6's Resource Compiler (RC.EXE). To do this, Shift+Right-Click on an empty space in the temp folder in order to bring up the context menu and select Open command window here (the text may be different depending on your OS's language). Type the following command and hit Enter:
      Code:
      "%ProgramFiles%\Microsoft Visual Studio\VB98\Wizards\RC.EXE" <insert filename here>.rc
      Change the path above so that it points to where RC.EXE is on your PC.
    11. RC.EXE will probably complain of "error RC2104 : undefined keyword or key name: \xA7". If you don't get an error, skip the following step, otherwise open the modified resource script again.
    12. Search the .RC file for all instances of \" and replace them with "". Be careful though. Do not replace those characters if they are at the end of the line. Fortunately, there is only 1 such instance you need to look out for.

      The reason you need to do this is because VB6's ancient resource compiler apparently doesn't recognize the \" character sequence as an escape character for an embedded quotation mark; it uses doubled-up quotes ("") instead.
    13. If RC.EXE was able to successfully compile the resource script, you should now have no problems importing the merged resource file to any VB6 project.


    If you still can't make it work, you can just get the merged FCP.RES file I compiled here and move on.

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Nov 2016
    Location
    Italy
    Posts
    235

    Re: Integrate two different resource files

    Ok LaVolpe. Your suggestion at #6 worked. Now the file is read without errors. Thanks to all of you for your patience.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width