[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?
Re: Integrate two different resource files
Resource Hacker can add resources from a .RES file to another .RES file.
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".
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.
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
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.
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
Re: Integrate two different resource files
Don't have 7z installed. Did you try the sample code I provided?
Re: Integrate two different resource files
OK, try this if you're still interested in using Resource Hacker:
- Make a temporary folder in a location of your choice.
- Open FCP.RES with Resource Hacker.
- Click Action >> Save ALL Resources to an RC file ...
- 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.
- Open Themes.res using the same Resource Hacker instance (or close it and start a new instance if you prefer).
- Repeat steps 3-4 for Themes.res. Close Resource Hacker afterwards.
- 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.
- 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. - Save the modified resource script afterwards and close it.
- 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. - 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.
- 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. - 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.
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.