• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 694
  • Last Modified:

Adding Internationalization to MFC application

hi, i am using CString string inside my MFC dialog. I want to internationalize it, so that I can load it from the resources.(string table). Any idea how can i load a string from the resources into CString (say CString str). Thanks..
0
ncheeku14
Asked:
ncheeku14
1 Solution
 
waysideCommented:
It's very simple, just put the resource id in the constructor, casting it as a pointer. The constructor is smart enough to figure out if it is a resource id or not, and if it is it loads the resource:

CString my_string((LPCSTR)IDS_MY_STRING_ID);


CString also has a LoadString() member function to let you load the string from a resource at any time:

CString my_string;

my_string.LoadString(IDS_MY_STRING_ID);

0
 
mahesh1402Commented:
Try Something like this :

//Store the current resource handle
HINSTANCE hClientResources = AfxGetResourceHandle();

//Tell the client to use the .DLL's resources
AfxSetResourceHandle(::GetModuleHandle("SomeDll.dll"));

//Do something with the .DLL's resources
CString str;
strRes.LoadString(IDS_SOME_STRING1);

//Restore the client application resource handle
AfxSetResourceHandle(hClientResources);


This may be also useful 'Load a CString from DLL withhin DLL'
http://www.codeproject.com/win32/loadstringfromdll.asp

-MAHESH
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now