Adding Internationalization to MFC application

Posted on 2006-05-31
Last Modified: 2013-11-20
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..
Question by:ncheeku14
    LVL 12

    Expert Comment

    LVL 14

    Accepted Solution

    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;


    LVL 22

    Expert Comment

    Try Something like this :

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

    //Tell the client to use the .DLL's resources

    //Do something with the .DLL's resources
    CString str;

    //Restore the client application resource handle

    This may be also useful 'Load a CString from DLL withhin DLL'


    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Mac OS 9 (Classic Environment) vs. MacBook Pro OS 10 8 30
    Host to IP 7 66
    Named range not carried over 10 53
    sumHeights  challenge 17 51
    Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
    Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    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…

    755 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

    23 Experts available now in Live!

    Get 1:1 Help Now