Solved

Resource file conversion

Posted on 2003-11-07
6
439 Views
Last Modified: 2013-12-03
I have an old Borland C++ project I am converting to Visual C++ 7 (Visual Studio .NET 2003).  I notice that the resource file format that Borland uses is different than the Microsoft format... and some things do not transfer properly...

1) Borland static text controls (using the CONTROL keyword) can be any length, but MS throws a compile error is they are > 256 characters.  If I create a new static text control in MSVS it uses an LTEXT keyword... and this seems to support larger test strings properly.
2) Borland allowed escape characters (\") in static test controls... MS does not recognize this and generates an error.

Is there any way, short of redoing over 100 complex dialogs by hand (not an option) that I can convert a borland resource file to use the current Microsoft format automatically?

Anyone have a good source of documentation for resource files in general?  I have not been able to find ANYTHING on the borland format or the MS format...

Any light that you could shed on this for me would be greatly appreciated.

Jeff
0
Comment
Question by:jeffs1
  • 3
  • 3
6 Comments
 

Author Comment

by:jeffs1
Comment Utility
OK.. An update... I figured out how to get VStudio to update the .rc file to MS format... and also that the \n is replaced by "" in MS speak.  Two outstanding issues remain...

1) Any way around the apparent control text lilmit of 256 characters in MS .rc file?  All tags, CONTROL, LTEXT, EDITTEXT, etc. have the same limit... they all truncate at 256 characters... I have a bunch of larger static text controls that I will have to set programatically if there is no work around in the resource file itself.

2) Under Borland, global IDE project setting #defines are sent to both the C++ compiler and the resource compiler... I use these to conditionally compile in certain resources depending on the version of the exe I am building... under Visual Studio, it seems there are two separate project define settings... one for the C++ compiler and one for the resource compiler... I do not want to have to remember to adjust values in two places when I do a build (just asking for errors)... and I do not want to have to define a new build type, since it will complicate the settings that I change for ALL configs.  I need to have the IDE defined C++ compiler defines active in the resource compilation.  Any way to do this?

Thanks,
Jeff
0
 
LVL 19

Expert Comment

by:Dexstar
Comment Utility
jeffs1:

> 1) Any way around the apparent control text lilmit of 256 characters in MS
> .rc file?  All tags, CONTROL, LTEXT, EDITTEXT, etc. have the same limit...
> they all truncate at 256 characters... I have a bunch of larger static text
> controls that I will have to set programatically if there is no work around
> in the resource file itself.

I don't think there is a way to do that.  You may just have to use 2 controls where you used to be able to use 1.

> 2) Under Borland, global IDE project setting #defines are sent to both the
> C++ compiler and the resource compiler... I use these to conditionally compile
> in certain resources depending on the version of the exe I am building...
> under Visual Studio, it seems there are two separate project define settings...
> one for the C++ compiler and one for the resource compiler...
> Any way to do this?

In the properties of the resource, set the "condition" to be the #define that you want to use to indicate to include that resource, and then set that #define in the Preprocessor settings of your project.

I frequently set the condition property of an icon or an image to be "_DEBUG" and then add another one with the same ID, etc., that points to a different file with a condition of NDEBUG., so I can provide different images for the debug version of my project.

Hope that helps,
Dex*
0
 

Author Comment

by:jeffs1
Comment Utility
Thanks, Dex... You are correct that that will work... but my problem is that the DEFINES project settings are different for the C++ preprocessor and the Resource compiler.  I want to be able to set a global define in ONE place and have that control my C++ build and the resource build.  If I have to always rememebr to set it in two places I am just asking for trouble... in Borland, the project defines applied to the C++ preprocessor AND the resource compiler.  In VC++ they are separate...

I have looked at using the predefined macros... they provide a ProjectBuildConfig macro which is either Release or Debug, but no SolutionConfig macro...

There seems to be NO way to control the entire build of my app with a single define, defined in a single location, that controls both teh C++ preprocessor and the Resource compiler.

Jeff
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 19

Accepted Solution

by:
Dexstar earned 400 total points
Comment Utility
jeffs1:

Wow, I'm surprised.  I thought for sure that the project preprocessor definitions would carry over to the .rc file as well.  But, I tested it myself and sure enough, it does not.

However, I wouldn't say there is NO way to do it.  I have a few suggestions:

1) Use an include file.  You can include this .h file in you StdAfx.h, and in .rc file via the "Edit -> Resource Includes" command.  Then you can just edit that file to set #defines for everything.

2) VS has a great macro environment.  You can write a quick macro that will copy the project's preprocessor settings to the .rc file's preprocessor settings, and then compiles.  If you want some help with the macro, I can do that...

Dex*
0
 

Author Comment

by:jeffs1
Comment Utility
Dex,

Thanks for the recommendations... I think I will go with the include file method... that should do the job... the IDE compiler define settings are a bit clunky anyway... and I have not found a way to make the properties dialog default to "All configs" instead of the active config... I cannot tell you how many times I have made a change to the active config when I intended it for both Debug and release configs because I forgot to select the "All configs".

Looks like using the "C/C++, Advanced, Force Includes" setting will guaranteer the include file be included for every line of every C++/h files processed without having to include it separately in each file.

Thanks for your suggestions and help.

Jeff
0
 
LVL 19

Expert Comment

by:Dexstar
Comment Utility
Thanks for the info... I had never used that option, so it slipped my mind completely!  :)

Glad you got a solution,
Dex*
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now