Page 1 of 1

Can not use resources with _ (Underscore)

Posted: Wed May 09, 2007 9:50 am
by Patrick Mast
Hello,

We have a very interesting problem with Microsoft Compatibe DLL files build from resources. If we compile the resource file with Borland, the problem goes away.

If we use a _ (underscore) in a resource name, and there is another resource name that begins with the same letter as the one with the _ in it, the app crashes if the resource name is a dialog or does not show the bitmap if the resource is a bitmap.
We found out that this is because the app can not find the resource name without the _ in it if there is a resource that starts with the same letter.

For example:
This does NOT work:
IN_DBFYES
INSERT -> Starts with IN

This works:
IN_DBFYES
NOINSERT -> Works because this resource name does NOT start with IN

This is the source for a reduced sample:

PRG:

Code: Select all

#include "FiveWin.ch"

Function Test_Resource()
   LOCAL oDlg, oBmp
   
   SET RESOURCES TO "Test.dll"

   DEFINE DIALOG oDlg TITLE "Dll problem" FROM 0,0 TO 200,500 PIXEL

   @ 10,10  IMAGE oBmp RESOURCE "INSERT"    SIZE 20, 20 PIXEL OF oDlg        
   @ 10,40  IMAGE oBmp RESOURCE "CHANGE"    SIZE 20, 20 PIXEL OF oDlg      
   @ 10,70  IMAGE oBmp RESOURCE "IN_DBFNO"  SIZE 20, 20 PIXEL OF oDlg      
   @ 10,100 IMAGE oBmp RESOURCE "IN_DBFYES" SIZE 20, 20 PIXEL OF oDlg      
                                     
   ACTIVATE DIALOG oDlg CENTERED      
   
RETURN NIL
RC:

Code: Select all

IN_DBFYES     BITMAP             "BITMAPS\\IN_DBF_YES.BMP"   
IN_DBFNO      BITMAP             "BITMAPS\\IN_DBF_NO.BMP"    

INSERT        BITMAP             "BITMAPS\\INSERT.BMP"       
CHANGE        BITMAP             "BITMAPS\\CHANGE.BMP"
To download the source to build this test app, please download
http://s194970364.onlinehome.us/Test_resource.zip

We are puzzled why this works with a Borland compiled DL, and NOT with a Microsoft build DLL.

Can someone confirm, or even better, is there a solution or bugfix for this? :D

Thanks!

Patrick Mast

Posted: Wed May 09, 2007 9:57 am
by Antonio Linares
Patrick,

Try to write the resources this way:

IN_DBFYES BITMAP "BITMAPS/IN_DBF_YES.BMP"
IN_DBFNO BITMAP "BITMAPS/IN_DBF_NO.BMP"

INSERT BITMAP "BITMAPS/INSERT.BMP"
CHANGE BITMAP "BITMAPS/CHANGE.BMP"

Posted: Wed May 09, 2007 10:00 am
by Antonio Linares
Patrick,

You may also (binary) compare the RES files from Borland and Microsoft to check what the differences are

Posted: Wed May 09, 2007 11:07 am
by Patrick Mast
Antonio Linares wrote:Patrick,

Try to write the resources this way:
IN_DBFYES BITMAP "BITMAPS/IN_DBF_YES.BMP"
IN_DBFNO BITMAP "BITMAPS/IN_DBF_NO.BMP"
INSERT BITMAP "BITMAPS/INSERT.BMP"
CHANGE BITMAP "BITMAPS/CHANGE.BMP"
No.. It does not fix it.

Patrick

Posted: Wed May 09, 2007 11:16 am
by Antonio Linares
Patrick,

Have you binary compared the two RES files ?

Posted: Wed May 09, 2007 11:22 am
by Patrick Mast
Antonio Linares wrote:Have you binary compared the two RES files ?
Yes, and they have a few bytes difference. You can download both BCC and MSVC build DLL, MAP, RC and RES from here:
http://s194970364.onlinehome.us/Test_resource_.dll.zip (32KB)

Those RES files are binary files, so, I only "See" differences, WHAT they are, I have no clue :)

I also tried to build the MSVC DLL with Resource Builder form http://www.resource-builder.com but it has the same problem. So, it seems it's not the "building" itself that's the problem, but maybe the reading of the DLL by the EXE?

Patrick

Posted: Wed May 09, 2007 11:38 am
by Antonio Linares
Patrick,

Have you tried to place the Borland RES file into the Microsoft compatible DLL ?

If you open the RES files with PellesC, they look exactly the same except that Borland is using Dutch (Belgium) instead of English (United States)

Posted: Wed May 09, 2007 11:48 am
by Patrick Mast
Antonio Linares wrote:Have you tried to place the Borland RES file into the Microsoft compatible DLL ?
Yes, but problem stays the same.
If you open the RES files with PellesC, they look exactly the same except that Borland is using Dutch (Belgium) instead of English (United States)
Ok. But since it also does not work with the RES file from Borland, it seems that it's not the RES file.

Do you think that's the bug is in BUILDING the DLL, or maybe in the EXE READING the DLL? I seem to be thinking its the READING?

Patrick

Posted: Wed May 09, 2007 11:53 am
by Antonio Linares
Patrick,

I think the difference comes from building the DLL, as the DLL reading is performed by standard Windows API functions

Posted: Wed May 09, 2007 11:55 am
by Antonio Linares
Patrick,

PellesC IDE properly opens the Borland DLL, but fails opening the other DLL with error: "user stopped resources enumeration"

Posted: Wed May 09, 2007 11:58 am
by Patrick Mast
Antonio Linares wrote:I think the difference comes from building the DLL, as the DLL reading is performed by standard Windows API functions
Ok.
Now, problem is, I build the MSVC Compatible Testdll with xHarbour Builder AND for test also with Resoure Builder, and they both show the same problem.

Any more ideas?

Patrick

Posted: Wed May 09, 2007 12:00 pm
by Antonio Linares
Have you tried to build the DLL using MSVC ?

Posted: Wed May 09, 2007 1:03 pm
by Patrick Mast
Antonio Linares wrote:Have you tried to build the DLL using MSVC ?
It works OK when I build the DLL with Visual Studio 2005.

Patrick