Can not use resources with _ (Underscore)

Can not use resources with _ (Underscore)

Postby Patrick Mast » Wed May 09, 2007 9:50 am

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  Expand view  RUN
#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  Expand view  RUN
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
User avatar
Patrick Mast
 
Posts: 246
Joined: Sat Mar 03, 2007 8:42 pm

Postby Antonio Linares » Wed May 09, 2007 9:57 am

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"
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Wed May 09, 2007 10:00 am

Patrick,

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

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Patrick Mast » Wed May 09, 2007 11:07 am

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
User avatar
Patrick Mast
 
Posts: 246
Joined: Sat Mar 03, 2007 8:42 pm

Postby Antonio Linares » Wed May 09, 2007 11:16 am

Patrick,

Have you binary compared the two RES files ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Patrick Mast » Wed May 09, 2007 11:22 am

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
User avatar
Patrick Mast
 
Posts: 246
Joined: Sat Mar 03, 2007 8:42 pm

Postby Antonio Linares » Wed May 09, 2007 11:38 am

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)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Patrick Mast » Wed May 09, 2007 11:48 am

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
User avatar
Patrick Mast
 
Posts: 246
Joined: Sat Mar 03, 2007 8:42 pm

Postby Antonio Linares » Wed May 09, 2007 11:53 am

Patrick,

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

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Wed May 09, 2007 11:55 am

Patrick,

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

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Patrick Mast » Wed May 09, 2007 11:58 am

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
User avatar
Patrick Mast
 
Posts: 246
Joined: Sat Mar 03, 2007 8:42 pm

Postby Antonio Linares » Wed May 09, 2007 12:00 pm

Have you tried to build the DLL using MSVC ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Patrick Mast » Wed May 09, 2007 1:03 pm

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
User avatar
Patrick Mast
 
Posts: 246
Joined: Sat Mar 03, 2007 8:42 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 35 guests