Multi-Language Programming by David Wendt Listing One STRINGTABLE PRELOAD DISCARDABLE LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US BEGIN IDS_LINE1, "line 1" IDS_LINE2, "line 2" END STRINGTABLE PRELOAD DISCARDABLE LANGUAGE LANG_FRENCH, SUBLANG_FRENCH BEGIN IDS_LINE1, "ligne 1" IDS_LINE2, "ligne 2" END Listing Two // start in English LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US STRINGTABLE PRELOAD DISCARDABLE BEGIN IDS_LINE1, "line 1" IDS_LINE2, "line 2" END // switch to French LANGUAGE LANG_FRENCH, SUBLANG_FRENCH STRINGTABLE PRELOAD DISCARDABLE BEGIN IDS_LINE1, "ligne 1" IDS_LINE2, "ligne 2" END Listing Three LIBRARY "MLDLL" DESCRIPTION 'Multi-Language Resource DLL' EXPORTS ; no exports for this DLL Listing Four 3 TEXTINCLUDE DISCARDABLE BEGIN "#include ""english.rc""\r\n" "#include ""french.rc""\r\n" "#include ""german.rc""\r\n" "\0" END ... #ifndef APSTUDIO_INVOKED // Generated from the TEXTINCLUDE 3 resource. #include "english.rc" #include "french.rc" #include "german.rc" #endif //this is the last line of the file Listing Five // MLTestDlg.cpp : implementation file #include "stdafx.h" #include "MLTest.h" #include "MLTestDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif /////////////////////////////////////////////////////////// // CMLTestDlg dialog CMLTestDlg::CMLTestDlg(CWnd* pParent /*=NULL*/) : CDialog(CMLTestDlg::IDD, pParent) { //{{AFX_DATA_INIT(CMLTestDlg) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } void CMLTestDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CMLTestDlg) // NOTE: the ClassWizard will add DDX and DDV calls here //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CMLTestDlg, CDialog) //{{AFX_MSG_MAP(CMLTestDlg) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() //}}AFX_MSG_MAP END_MESSAGE_MAP() // CMLTestDlg message handlers BOOL CMLTestDlg::OnInitDialog() { CDialog::OnInitDialog(); // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon // TODO: Add extra initialization here return TRUE; // return TRUE unless you set the focus to a control } void CMLTestDlg::OnSysCommand(UINT nID, LPARAM lParam) { CDialog::OnSysCommand(nID, lParam); } void CMLTestDlg::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); // Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon dc.DrawIcon(x, y, m_hIcon); } else { CDialog::OnPaint(); } } HCURSOR CMLTestDlg::OnQueryDragIcon() { return (HCURSOR) m_hIcon; } Listing Six ... #ifdef _AFXDLL Enable3dControls(); #else Enable3dControlsStatic(); #endif HANDLE hResHdl = LoadLibrary( "MLDLL.DLL" ); if( hResHdl ) AfxSetResourceHandle( (HINSTANCE)hResHdl ); else { AfxMessageBox( "Could not load resource module" ); return FALSE; } CMLTest dlg; // existing line ... Listing Seven m_comboBox.AddString( CString((LPCSTR)IDS_CB_STRING1) ); m_comboBox.AddString( CString((LPCSTR)IDS_CB_STRING2) ); m_comboBox.AddString( CString((LPCSTR)IDS_CB_STRING3) ); m_comboBox.SetCurSel( 0 ); m_listBox.AddString( CString((LPCSTR)IDS_LB_STRING1) ); m_listBox.AddString( CString((LPCSTR)IDS_LB_STRING2) ); m_listBox.AddString( CString((LPCSTR)IDS_LB_STRING3) ); 3