Storing strings in header file via resource file (.rc file) ?

Hi:



My application needs to support multiple languages. I'm now planning to 
strong strings in multiple string tables in the rc file; where each string 
table contains one language. My question is: will it be much simpler to 
store those strings in multiple header files? In this case a string can be 
used directly without the need to use CString to load each string before 
using it.



Please let me know if I'm missing some advantages using the rc file to store 
strings.



Thanks in Advance.



Polaris


0
etpolaris (100)
10/25/2004 7:31:00 PM
vc.mfc 33608 articles. 0 followers. Follow

10 Replies
1234 Views

Similar Articles

[PageSpeed] 24

"Polaris" <etpolaris@hotmail.com> wrote in message news:<elVZpksuEHA.3024@TK2MSFTNGP15.phx.gbl>...
> Hi:
> 
> 
> 
> My application needs to support multiple languages. I'm now planning to 
> strong strings in multiple string tables in the rc file; where each string 
> table contains one language. My question is: will it be much simpler to 
> store those strings in multiple header files? In this case a string can be 
> used directly without the need to use CString to load each string before 
> using it.
> 
> 
> 
> Please let me know if I'm missing some advantages using the rc file to store 
> strings.
> 
> 
> 
> Thanks in Advance.
> 
> 
> 
> Polaris


Consider this. If you put all of your strings for a given language in
one rc file and build a dll out of it, then you can switch your
language on the fly - just point user to download language dll from
net and put it into the programs folder. Another plus is that all
localization stuff is separated from program - you can provide a new
version of resources independantly from the program itself. Or make
your subvendor provide localization for you before releasing a product
for a given country - no need to rebuild the program itself.
0
kochkarev (130)
10/26/2004 7:56:34 AM
Hello!

On Mon, 25 Oct 2004 12:31:00 -0700, Polaris wrote:

> Please let me know if I'm missing some advantages using the rc file to store 
> strings.
> 
The nice thing about using string tables in .rc is that you specify which
language the table is and then the program automagically will select the
'correct' language according to the language of your Windows. I.e. If you
are running an English Windows then your program will select the English
resources. If you are using a German Windows then your program will select
the German resources. If you are running a Windows in a language where your
program have no resources it will select the default resources (which for
me always are English(US), but...)

Remember that you can make all resources language dependent, e.g. Dialogs,
toolbar's, etc.

The only drawback I have found is that the user can't select a language
different from the Windows version he/she are using. I.e. If the user is
running an English Windows he can't have your program in German.

Yeah, and then if you have lots of resources and lots of languages then
your program will get bigger, but "normally" it doesn't matter...

// Anders
0
10/26/2004 8:23:52 AM
Anders Eriksson wrote:
> The only drawback I have found is that the user can't select a language
> different from the Windows version he/she are using. I.e. If the user is
> running an English Windows he can't have your program in German.

Have you tried SetThreadLocale? Doesn't work in Win9x, though.

0
mac1 (347)
10/26/2004 11:21:06 AM
Mihajlo Cvetanovic <mac@RnEeMtOsVeEt.co.yu> wrote in 
news:417E3322.4070302@RnEeMtOsVeEt.co.yu:

> Anders Eriksson wrote:
>> The only drawback I have found is that the user can't select a language
>> different from the Windows version he/she are using. I.e. If the user is
>> running an English Windows he can't have your program in German.
> 
> Have you tried SetThreadLocale? Doesn't work in Win9x, though.
Auto-selecting the language based on thread locale is broken starting
with Windows 2000 (cased by changes to support MUI).


-- 
Mihai
-------------------------
Replace _year_ with _ to get the real email
0
10/27/2004 4:19:42 AM
Mihajlo Cvetanovic <mac@RnEeMtOsVeEt.co.yu> wrote in 
news:417E3322.4070302@RnEeMtOsVeEt.co.yu:

> Anders Eriksson wrote:
>> The only drawback I have found is that the user can't select a language
>> different from the Windows version he/she are using. I.e. If the user is
>> running an English Windows he can't have your program in German.
> 
> Have you tried SetThreadLocale? Doesn't work in Win9x, though.
Auto-selecting the language based on thread locale is broken starting
with Windows 2000 (cased by changes to support MUI).
On the other side, Windows 95/98/Me do not support SetThreadLocale.
The only use for SetThreadLocale is Windows NT. Not too much :-)


-- 
Mihai
-------------------------
Replace _year_ with _ to get the real email
0
10/27/2004 4:20:34 AM
Mihai N. wrote:
>>Have you tried SetThreadLocale? Doesn't work in Win9x, though.
> 
> Auto-selecting the language based on thread locale is broken starting
> with Windows 2000 (cased by changes to support MUI).
> On the other side, Windows 95/98/Me do not support SetThreadLocale.
> The only use for SetThreadLocale is Windows NT. Not too much :-)

In what way is it broken? I just managed to load two different strings 
on Win2000 with VC7:

TCHAR szTemp[255];
SetThreadLocale(MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT));
LoadString( NULL, 101, szTemp, 255 );
SetThreadLocale(MAKELCID(MAKELANGID(LANG_SERBIAN,SUBLANG_SERBIAN_LATIN),SORT_DEFAULT));
LoadString( NULL, 101, szTemp, 255 );

And while we're at it there's a bug in VC7 where RC editor inserts 
macros LANG_SERBIAN_LATIN and LANG_SERBIAN_CYRILLIC but those macros 
don't exist, so for every new project I have to insert this in Resource 
Includes:

#define LANG_SERBIAN_LATIN LANG_SERBIAN
and/or
#define LANG_SERBIAN_CYRILLIC LANG_SERBIAN

Can someone confirm this bug in VS2005?

0
mac1 (347)
10/27/2004 12:40:17 PM
> In what way is it broken? I just managed to load two different strings 
> on Win2000 with VC7:
> 
> TCHAR szTemp[255];

See the doc for SetThreadLocale 
(http://msdn.microsoft.com/library/default.asp?url=/library/en-
us/intl/nls_52lh.asp)
Quote: "Windows 2000/XP: Do not use SetThreadLocale to select a UI language. 
To select the proper resource that is defined with a LANGUAGE statement, use 
FindResourceEx."

Or here:
http://www.microsoft.com/globaldev/getWR/steps/WRG_lclmdl.mspx
Quote: "On Microsoft Windows NT 4.0, many applications used the thread locale 
to define which language resources should be retrieved and displayed. 
However, this practice represents a misusage of the thread locale. (In 
Windows 2000 and Windows XP, the system's resource loader does not default to 
the thread locale variable.) As you'll see, resource languages should always 
be driven by and follow the user interface (UI) language variable."

Or here:
http://www.microsoft.com/globaldev/drintl/columns/009/default.mspx
Quote: "Thread Locale: This per thread locale is initialized with the 
currently selected user locale value. Formerly used to retrieve language 
specific resources from a multilingual resource file (see 
GetThreadLocale/SetThreadLocale for more info). Should only be used to 
synchronize the thread locale of a server application with the user locale of 
a client machine. This can only be set programmatically."


-- 
Mihai
-------------------------
Replace _year_ with _ to get the real email
0
10/28/2004 6:57:04 AM
Mihai N. wrote:
>>In what way is it broken? I just managed to load two different strings 
>>on Win2000 with VC7:
>>
>>TCHAR szTemp[255];
> 
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/nls_52lh.asp
> 
> http://www.microsoft.com/globaldev/getWR/steps/WRG_lclmdl.mspx
> 
> http://www.microsoft.com/globaldev/drintl/columns/009/default.mspx

So we're discouraged from using SetThreadLocale for choosing the 
language of resources, because it may stop working in some Win XP2?

For non-MFC applications there's FindResourceEx, but bow should I change 
the language in MFC applications (w/o resorting to resource only dlls)?

0
mac1 (347)
10/28/2004 10:08:36 AM
No. There is a reason resource files were created for this purpose, and that is because it
is far easier to store the strings in the resource file than in header files. It is easier
to change languages. For decades, strings were kept in header files, and the practice was
quite deliberately abandoned because of its costs of maintenance and lack of flexibility.

Why does CString::LoadString make the slightest difference?
					joe

On Mon, 25 Oct 2004 12:31:00 -0700, "Polaris" <etpolaris@hotmail.com> wrote:

>Hi:
>
>
>
>My application needs to support multiple languages. I'm now planning to 
>strong strings in multiple string tables in the rc file; where each string 
>table contains one language. My question is: will it be much simpler to 
>store those strings in multiple header files? In this case a string can be 
>used directly without the need to use CString to load each string before 
>using it.
>
>
>
>Please let me know if I'm missing some advantages using the rc file to store 
>strings.
>
>
>
>Thanks in Advance.
>
>
>
>Polaris
>

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15974)
10/28/2004 9:37:29 PM
> So we're discouraged from using SetThreadLocale for choosing the 
> language of resources, because it may stop working in some Win XP2?
Correct.

> For non-MFC applications there's FindResourceEx, but bow should I change 
> the language in MFC applications (w/o resorting to resource only dlls)?
The "best practice" now is satelite DLLs.
Create language-only dlls (one per language, resources only).
Load the DLL and load the resources using that hInstance.
Or, for MFC, call AfxSetResourceHandle(hInstance), then all res. calls will
use that dll.


-- 
Mihai
-------------------------
Replace _year_ with _ to get the real email
0
10/29/2004 8:23:18 AM
Reply:

Similar Artilces:

Help with profiles .pst files and roaming profiles
Hi all and thanks in advance for the future answers; Well, we have a enviromente that goes like this: 1 Domain Controller 1 Mail Server running KERIO MAIL SERVER 2 Terminal Servers running CITRIX PS 4.5 1 Server running the citrix console The problem: We have like 50 users now that connect to servers A or B and have their roaming profile working fine, all files and configs come and go, with the exception of the OUTLOOK profile. When i had to add SERVER B to the system, i had to copy users folders from server A and apply the same permissions one by one, otherwise outlook would not work and ...

Single Click Files
Realized that I can no longer single click to open files. Found at Folder Options the single click radio button is grayed-out now. Can this be changed? ...

Audio file captured in Producer will not open in Windows Media
Made an audio only file in Windows Producer and the file is in the correct folder in My Audios Files. The file appears in Producer as a Windows Media File [.wma}, it has the WM icon and says it is filed appropriately. I saved the Project and gave the Project a different name. I went to Windows Media to open the file to play and Media cannot open the file because it doesn’t recognize the format. If Producer saved the file as a ..wma file why can’t Media open the file? When I tried to open the file in Media, it is not apparent in a My Audios folder when I pick a .wma file type to open; h...

Can't "Hide Header Information" in Task View Reading Pane
I'm running Outlook 2003, SP3. In the Task View Reading Pane, the header information takes up a lot of screen space. I'd like to get rid of it. I have found two dialogs with a checkbox for "Hide Header Information", but checking and unchecking that box has no effect. It appears to be a bug. Any suggestions? ...

Insert file name in header without showing extension
I know how to get the filename into a header/footer. Is there any way to get the filename in the header/footer WITHOUT showing the filename extension? 1) Click on 'My Computer' > 'Tools' > 'Folder Options...' > View tab and check the option "Hide extensions for known files". OR: 2) If you don't want to change the way your computer displays file names - make use of a Macro: ------------------------------------------------------- Sub Header_FileName_No_Extension() On Error Resume Next LFN = InStrRev(ActiveWorkbook.Name, "...

How to remove read only protection from a file?
Everytime I save text or photos to a cd rom (rw), it saves it as a read only file which I can't manipulate. Why is this and how do I remove the read only protection from the file? Please help. Thanks I'm assuming you are trying to open and modify the file while it is still on the CD. Which you can't do, how could you, it's not a hard-drive. Copy the file off the CD onto your hard drive to modify the file. As for removing file protection, right click file and select properties to locate the file attributes. oh btw this forum is for questions concerning the use of Micros...

Image in Excel File is not getting copied
In a Excel File I have inserted one Image from Insert --> Picture --> Form File ... Now when programatically I use System.IO.File.Copy(srcFile, destFile) and make a copy of this excel file, then all the data in Excel File is copied but that image which I inserted is not shown in the destination file. What is the problem here? Thanks, Ashish ...

Finding Text String Within A String With A Formula
I need to find a text string within a string. Because I am not familiar with programming, I prefer to do this with a formula. This is what I need to do - extract text that meets this criteria: SSN-XXXXXXXXX SSN-XXX-XX-XXXX SSN - XXXXXXXXX SSN - XXX-XX-XXXX EXAMPLES OF STRINGS TO BE SEARCHED: ROBERT PALMER 123 ELM ST WINNBORO 555-1212 SSN-123456789 PR 34290 #< 14932 ACACIA GARDEN HEIGHTS 979/830-9086 COST ASSOC SSN - 123-45-6789 Thanks! Sandi =MID(SUBSTITUTE(SUBSTITUTE(B8," ",""),"-",""),FIND("SSN",SUBSTITUTE(SUBSTITUTE(B...

Exch 2003 store.exe terminates when ESM Replication Status selected
Exch 2003 SP1 on W2K SP4 - had been 5.5 until moving to Exch 2K swing server. 5.5 removed and Exch 2003 SP1 installed, seemingly OK. Weird problem - if I click on ESM->Administrative groups-> group ->Servers-> server->First Storage Group->Public Folder Store(server) and then click on Replication Status, after a delay I recieve a popup saying, "An error occurred while retrieving the requested information. The Microsoft Exchange Information Store service is not running or the Microsoft Exchange Server computer is unavailable. ID no: c103047d Exchange System Manager...

Multi Store Vouchers
I do not see a way for this to work. I want to be able to give out store credit to our customers but there does not seem a way to make this work for multiple stores. In a single store setup everything is stored in the Voucher table. These vouchers are uploaded during the HQ synchronization but each store does not have access to other stores voucher's. Does anyone have any insight on how I could get this resolved? Thanks, Dan I take it you are trying to issue Store Credit for returns, not actually trying to implement a voucher system for gift cards/certificates. If this is corre...

Stored Procedure error message
Hi, I have written scipt in Dex to create tables. After I have added chunk file, tables are creating properly. But the issue is after login into Great Plains I am getting the following error "The Stored Procedure GrantAccess() of form Sql maintenance : 69: pass through Sql returned the following results :DBMS :15151, Microsoft Dynamics GP:0" Any Idea Please... Jack Hi Friends, I got the solution my slef and issue has resolved.. Thanks, Jack "Jack" wrote: > Hi, > > I have written scipt in Dex to create tables. After I have added chunk file, > table...

Opening a file in a macro (network)
I have a macro that requires opening a file in My Documents. This may be a networking question that may require onsite help but what I was wondering is if there is a way in the code to specify to open a file in My Documents from "the computer you're on" for example (not sure how to word that). I'm trying to avoid having to create a macro for each computer because I will have the same file stored in My Documents on each computer. Does that make sense? For example, the code right now reads (for the computer I am currently on - "Blinds etc" is how the computer i...

HQ/Store date mismatch
We just deployed our 3rd store and eveyrthing was working fine, transactions were being uploaded and everything. Then, the store ops DB computer got moved, and I guess at some point someone changed the date on the computer to be a month in advance. Now, all of our transactions from 4/25/2006 to 4/27/2006 are actually in the DB as 5/25/2006 to 5/27/2006. I just discovered the problem and changed the date on the Store Ops machine, but I don't know what the best way to fix these transactions is, or if it is even possible. What I'd like to do is go change all of these transac...

Money file encrypted
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I'm using Money 2004 with a password protected file. Is that file encrypted on disk? IOW if someone steals a copy of that file and they don't know the password, is there any chance of them being able to read the file? TIA - -- To reply by email remove "_nospam" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (MingW32) iEYEARECAAYFAkPVOc8ACgkQzIf+rZpn0oTEKwCgmW9Sa+b/Bl0XSl1wtmYNCRjc TDQAn33pG8HNcvlsB1fp4nU5FWCVkoBo =ERGM -----END PGP SIGNATURE----- Yes. The only question is degree of difficulty. "Chuck" <skilo...

opening dbf file in Excel: "cannot open protected file"
Office 2007 seems unwilling to open any of the dbf's that I'm attempring to move over from an old db program. None appear to have any special security limitations. I've googled the problem and all I get are statements about Excel 2002 and dbf files that begin with the letter "c". Anyone having a similar problem? Thanks. ...

Running headers with a logo
Dear Experts: I would like to place a logo as a running header on even and odd pages of the current document: It has the following setup Page Layout: =95 Different even and odd headers and footers =95 Mirror Margins The logo (c:\CompanyLogo.png) to be inserted should have the following properties: =95 Picture Layout: in front of text =95 Picture Position: Horizontal: Book layout, outside of margin Vertical: Absolute position, 1.4 cm below Page I know the code to insert headers programmatically such as sect.PageSetup.OddAndEvenPagesHeaderFooter =3D True s...

Average Sales per Store
Need help modifying the RMS "Average Sales per Store" report that is found in CustomerSource. Would like to add filters for Department and Category if possible. I have tried to modify it myself, but I'm a beginner at this and I keep coming up short. One other thing that may be useful is if it can summarize by date also - would be nice to see how the values change over the course of a week or so. "Jason Kelton" wrote: > Need help modifying the RMS "Average Sales per Store" report that is found in > CustomerSource. Would like to add filters for D...

Outlook XP autofill To field
Outlook XP ... When typing in names in the To field of new messages Outlook will start to show names that have either already been typed, sent to or appear in the Contact list. Where is this "autofill" list kept? Is it user accessible? I'd like to get rid of some of the names that are not already in my Contacts. You can just use the down arrow key to highlight a name that is incorrect or whose address has changed and press delete. --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. After searching google.groups.com and finding ...

best way to access shared xl file on web
I am trying to find the best way to update a spreadsheet on the web. I would like to use the shared workbook feature and save it in a protected folder. Would i have to save the file as htm? And is there an easier way to access the file then typing the full http access through the file open menu? Thanks ...

Word display a strange message while we open a file for the first time
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel Dear all, <br> I have some iMac and user use it to be logged on a server. Network account are created on the server. Also their Home folder and documents are on the server. <br><br>When user opens a file (i think mainly the docx) their get that error message: <br><br>&quot;file&quot; is being used by &quot;another user&quot;. Do you want to make a copy? <br><br>We are all sure that no other user is reading or writing on that file. And this happen only wh...

How do I alternate headers on facing pages?
This may have been answered before on this group, but a search of existing posts doesn't yield anything. I've been setting up a book to publish, a catalog really, based up the contents of a database. Publisher 2003 makes easy work of this, but I need to be able to add the author's name as a header for the odd numbered pages, and the the chapter title for the even numbered pages, and so far several purchases of books, and trips to the library has yielded nothing. Is publisher 2003 capable of doing this? This is so basic to book publishing that I'd be surprised if it doesn...

Online IT filing
welcome to the hassale free world of taxation. File your IT returns online on a click with just RS.99. ...

How to insert picture into the header?
I am trying to insert a picture into the header....can this be done? When I do copy/paste nothing happens. Thanks. Assuming you mean header as in header/footer in printed page(s). If you have Excel 2002 or newer you can use graphics in a header of footer. Versions prior to that required work-arounds to place the graphic in top row and use top row as "Rows to repeat at top" Gord Dibben MS Excel MVP On Mon, 26 Jun 2006 13:50:31 -0400, "SP" <justme@yourmail.com> wrote: >I am trying to insert a picture into the header....can this be done? When I >do ...

Store Credit multi Store
Good Day, Can someone give advice about how to set up Store Credits for a multi store enterprise. Currently the client use store credits/vouchers at store location only and can only redeem a Store Credit where it was issued. We would like to set it up so that they can redeem a store credit at any store location no matter where it was issued. Three stores connected via HQ. Thanks in Advance. I believe you can set up an account type and call it 'store credit' or something, then when you enter the new customer information for the person receiving store credit you simply assig...

encoding wmv file
hello I have a sample application developed in MFC dialog based project using directx sdk 9. the sample captures video from a webcam and saves it to a wmv file now i have to put that video into streaming server. i beleive that i will have to encode the wmv file using some codecs to put it into streaming server. i want to do the capturing and encoding simultaneously. below is a portion of my code to capture video // capture video pBuilder->RenderStream(&PIN_CATEGORY_CAPTURE, // Pin category &MEDIATYPE_Video, // Media type p...