如何实现中英文界面的动态切换?高分奉送

时间:2021-10-08 20:15:19
我的办法是在一个dll中加入所需的英文资源rc,完成后再在执行文件中主要写如下代码:
HINSTANCE hinstance = ::LoadLibrary("resourceeng.dll" );
if( hinstance == NULL ) return;
::AfxSetResourceHandle( hinstance );
但这样好象不行,怎么做?

3 个解决方案

#1


你可以为每一种语言建立一个资源动态库,在运行过程中根据不同的选择动态装入合适的动态库,并且所有的界面元素都从这个动态库中装入就行了——上面不应该有问题吧

#2


我刚完成一个国际化的网络应用程序,我是这样做的.
1:思路,UI的国际化分为两个部分,菜单和其它资源.
2:国际化的工作也就分为两个部分,菜单资源的ReLoad和其它UI(文本)的Reload.
3:菜单的ReLoad使用下面的函数(我的风格尽量不用MFC),菜单可以直接在资源文件.rc
中编辑.
BOOL ChangeMenu()
{
//////////////////////////////////////////////
//////It's difficult to change the menu///////
/////It's important to set m_hMenuDefault/////
/////to hNewMenu.First,I haven't do this,/////
/////error will occur whenever the window/////
/////be closed.The reason is,memory address///
////will change if HMENU changed.Yet,I can////
///////not find any information about ////////
///////m_hMenuDefault in Help document////////

HINSTANCE     hInst;
HRSRC         hRc;
HGLOBAL       hGl;
WORD          lang;
MENUTEMPLATE* lpTemp;
HMENU         hOldMenu,hNewMenu;

lang=GetCurrentLanguage();
hInst=AfxGetResourceHandle();
hRc=::FindResourceEx(hInst,RT_MENU,
MAKEINTRESOURCE(IDR_MAINFRAME),lang);
if(hRc==NULL)
return FALSE;
hGl=::LoadResource(hInst,hRc);
if(hGl==NULL)
return FALSE;
lpTemp=(MENUTEMPLATE *)::LockResource(hGl);
if(lpTemp==NULL){
::FreeResource(hGl);
return FALSE;
}
hNewMenu=::LoadMenuIndirect(lpTemp);
if(hNewMenu==NULL){
::FreeResource(hGl);
::UnlockResource(hGl);
return FALSE;
}
hOldMenu=::GetMenu(m_hWnd);
if(hOldMenu)
::DestroyMenu(hOldMenu);
::SetMenu(m_hWnd,hNewMenu);
m_hMenuDefault=hNewMenu;
::FreeResource(hGl);
::UnlockResource(hGl);
return TRUE;
}
4:其它资源的Reload基于下面的思路:在资源文件.rc中全是英文资源,在textres.*文件中实现资源的Reload,看了下面的两个文件你应该会明白.
*****************textres.h****************************
#ifndef _TEXTRES_H
#define _TEXTRES_H

#include "resource.h"

typedef struct _text_item
{
UINT    resID;
LPCTSTR text;
} TEXT_ITEM,FAR* LPTEXT_ITEM;

typedef struct _lang_pointer
{
WORD        langID;
LPTEXT_ITEM lpTextItem;
} LANG_POINTER,FAR* LPLANG_POINTER;

void SetCurrentLanguage(WORD langID);
WORD GetCurrentLanguage();

int  LoadTextByID(UINT resID,LPTSTR string,int maxsize);
//maxsize should include the terminating null character

#endif

*************************************************************
#include "StdAfx.h"
#include "textres.h"

int gCurrentIndex;

//////////////////////////////
/////English Text Resource////
////Retrieve from .rc file////
TEXT_ITEM usaTextItem[]={
{0,NULL}
};

///////////////////////////////////
////Chinese Simplified Resource////
///////Retrive until resID==0//////
TEXT_ITEM chsTextItem[]={
{IDS_GAMP_APPTITLE,       "MailToFax 1.0"},
{IDS_FILTER,              "´«ÕæÎļþ|*.g3|ËùÓÐÎļþ|*.*|"},
{IDS_GAMP_BROWSE,         "ä¯ÀÀ"},
    {IDS_GAMP_NAMEANDFAX,     "Ãû³ÆºÍ´«ÕæºÅ:"},
    {IDS_GAMP_SUBJECT,        "Ö÷Ìâ"},
    {IDS_GAMP_SEND,           "·¢ËÍ"},
{IDS_GAMP_FILENAME,       "ÎļþÃû³Æ:"},
    {IDS_GAMP_COMMBOOK,       "ͨѶ²¾"},
    {IDS_GAMP_OK,             "È·¶¨"},
    {IDS_GAMP_CANCEL,         "È¡Ïû"},
    {IDS_GAMP_NEW,            "ÐÂÔö"},
    {IDS_GAMP_MODIFY,         "ÐÞ¸Ä"},
{IDS_GAMP_DELETE,         "ɾ³ý"},
    {IDS_GAMP_NAME,           "ÐÕÃû"},
    {IDS_GAMP_FAXNO,          "´«ÕæºÅ"},
    {IDS_GAMP_COMPANY,        "¹«Ë¾"},
    {IDS_GAMP_CANNOTBEEMPTY,  " ²»ÄÜΪ¿Õ."},
    {IDS_GAMP_MUSTBENUMERIC,  " ±ØÐëÊÇÊý×Ö."},
    {IDS_GAMP_CANNOTBEZERO,   " ²»ÄÜΪÁã."},
    {IDS_GAMP_NODATAREMAINED, "ÒѾ­Ã»ÓÐÊý¾ÝÁË."},
    {IDS_GAMP_NOROWSELECTED,  "ÇëÏÈÑ¡ÔñÒ»ÐÐÊý¾Ý."},
    {IDS_GAMP_DATABASEERROR,  "Êý¾Ý¿â·ÃÎʳö´í."},
    {IDS_GAMP_DATAEXIST,      "Êý¾ÝÒѾ­´æÔÚ."},
    {IDS_GAMP_ORIGCOPY,       "Ç빺ÂòÕý°æÈí¼þ."},
    {IDS_GAMP_FINDBY,         "Ìõ¼þ²éѯ"},
    {IDS_GAMP_QUERY,          "²éѯ"},
    {IDS_GAMP_SELECTED,       "ÒѾ­Ñ¡Ôñ"},
    {IDS_GAMP_NEXT,           "ÏÂÒ»Ïî"},
{IDS_GAMP_NAMEFAXNONOTMATCH, "±ØÐë°´´Ë¸ñʽÊäÈë:\nName-FaxNo."},
    {IDS_GAMP_LENGTHTOOLONG,  "Ì«³¤ÁË."},
    {IDS_GAMP_NOFOUNDDATA,    "ûÓз¢ÏÖÆ¥ÅäµÄÏîÄ¿."},
    {IDS_GAMP_USERID,         "Óû§IDºÅ"},
    {IDS_GAMP_PASSWORD,       "Óû§¿ÚÁî"},
    {IDS_GAMP_EMAILADDRESS,   "»ØÓ¦EmailµØÖ·"},
    {IDS_GAMP_GATEWAY,        "Íø¹ØEmailµØÖ·"},
    {IDS_GAMP_SERVER,         "SMTP ·þÎñÆ÷"},
    {IDS_GAMP_PORT,           "SMTP ¶Ë¿Ú"},
    {IDS_GAMP_FAXNAME,        "´«Õæ»úÆ÷Ãû"},
    {IDS_GAMP_SYSCONFIG,      "ϵͳÉèÖÃ"},
    {IDS_GAMP_INVALIDVALUE,   " ÎÞЧµÄÊý¾Ý."},
    {IDS_GAMP_BETWEEN9999,    " ±ØÐëÏÞÖÆÔÚ1-9999."},
    {IDS_GAMP_OPENFILEERROR,  "´ò¿ªÎļþʱ³ö´í."},
    {IDS_GAMP_FAILTOOLBAR,    "´´½¨¹¤¾ßÌõʱ³ö´í."},
    {IDS_GAMP_SETSYSCONFIGFIRST, "ÇëÏÈÉèÖÃϵͳ²ÎÊý."},
{IDS_STATUS_SMTPFROM,     "·¢ËÍ SMTP from µØÖ·"},
    {IDS_STATUS_SMTPTO,       "·¢ËÍ SMTP to µØÖ·"},
    {IDS_STATUS_TRANSFERING,  "´«ÊäÕýÎÄÊý¾Ý..."},
    {IDS_STATUS_GETPORT,      "¼ìË÷ TCP/IP ÍøÂç¶Ë¿Ú..."},
    {IDS_STATUS_RETRIVEADDRESS, "¼ìË÷ internet µØÖ·..."},
    {IDS_STATUS_GETPROTOCOL,  "¼ìË÷ÍøÂçЭÒé..."},
    {IDS_STATUS_CREATESOCKET, "´´½¨ socket..."},
    {IDS_STATUS_ESTABLISHCONNECT, "½¨Á¢ÍøÂçÁ¬½Ó..."},
    {IDS_STATUS_GETHOSTNAME,  "¼ìË÷Ö÷»úÃû³Æ..."},
    {IDS_STATUS_CONNECTTOTCP, "Óë TCP ½¨Á¢Á¬½Ó..."},
    {IDS_STATUS_SENDHELO,     "·¢ËÍ HELO ÐÅÏ¢..."},
    {IDS_STATUS_REPLYHELO,    "½ÓÊÕ HELO µÄ»ØÓ¦..."},
    {IDS_STATUS_LASTTASK,     "×îºóµÄÈÎÎñ..."},
    {IDS_STATUS_TRANFORMOK,   "ÍøÂç´«Êä³É¹¦."},
    {IDS_STATUS_TRANSFORMERROR, "ÍøÂç´«Êäʧ°Ü."},
    {IDS_GAMP_READG3ERROR,    "¶Á .g3 Îļþʱ³ö´í£¬¿ÉÄÜËü²»ÊÇÕýÈ·µÄ¸ñʽ."},
{IDS_GAMP_FIRSTPAGE,      "ËüÒѾ­ÊǵÚÒ»Ò³ÁË."},
    {IDS_GAMP_LASTPAGE,       "ËüÒѾ­ÊÇ×îºóÒ»Ò³ÁË."},
    {IDS_GAMP_PAGE,           "Ò³ºÅ"},
    {IDS_GAMP_THREADLIST,     "ÔËÐеĴ«ÊäÏß³Ì"},
    {IDS_GAMP_CURSTATUS,      "µ±Ç°×´Ì¬"},
    {IDS_GAMP_TERMINATE,      "ÖÕÖ¹"},
    {IDS_GAMP_MEMORYERROR,    "ÄÚ´æ³öÏÖÑÏÖØ´íÎó!"},
{0,NULL}
};

///////////////////////////////////
///Chinese Traditional Resource////
///////Retrive until resID==0//////
TEXT_ITEM twnTextItem[]={
{IDS_GAMP_APPTITLE,       "MailToFax 1.0"},
{IDS_FILTER,              "‚÷ÕæÎļþ|*.g3|ËùÓÐÎļþ|*.*|"},
{IDS_GAMP_BROWSE,         "žgÓ["},
    {IDS_GAMP_NAMEANDFAX,     "Ãû·QºÍ‚÷ÕæÌ–:"},
    {IDS_GAMP_SUBJECT,        "Ö÷î}"},
    {IDS_GAMP_SEND,           "°lËÍ"},
{IDS_GAMP_FILENAME,       "ÎļþÃû·Q:"},
    {IDS_GAMP_COMMBOOK,       "ͨӍ²¾"},
    {IDS_GAMP_OK,             "´_¶¨"},
    {IDS_GAMP_CANCEL,         "È¡Ïû"},
    {IDS_GAMP_NEW,            "ÐÂÔö"},
    {IDS_GAMP_MODIFY,         "ÐÞ¸Ä"},
{IDS_GAMP_DELETE,         "„h³ý"},
    {IDS_GAMP_NAME,           "ÐÕÃû"},
    {IDS_GAMP_FAXNO,          "‚÷ÕæÌ–"},
    {IDS_GAMP_COMPANY,        "¹«Ë¾"},
    {IDS_GAMP_CANNOTBEEMPTY,  " ²»ÄÜ ‘¿Õ."},
    {IDS_GAMP_MUSTBENUMERIC,  " ±ØíšÊÇ”µ×Ö."},
    {IDS_GAMP_CANNOTBEZERO,   " ²»ÄÜ ‘Áã."},
    {IDS_GAMP_NODATAREMAINED, "Òѽ››]ÓДµ“þÁË."},
    {IDS_GAMP_NOROWSELECTED,  "ÕˆÏÈßx“ñÒ»ÐДµ“þ."},
    {IDS_GAMP_DATABASEERROR,  "”µ“þŽìÔL†–³öåe."},
    {IDS_GAMP_DATAEXIST,      "”µ“þÒѽ›´æÔÚ."},
    {IDS_GAMP_ORIGCOPY,       "ՈُÙIÕý°æÜ›¼þ."},
    {IDS_GAMP_FINDBY,         "—l¼þ²éÔƒ"},
    {IDS_GAMP_QUERY,          "²éÔƒ"},
    {IDS_GAMP_SELECTED,       "Òѽ›ßx“ñ"},
    {IDS_GAMP_NEXT,           "ÏÂÒ»í—"},
{IDS_GAMP_NAMEFAXNONOTMATCH, "±Øíš°´´Ë¸ñʽݔÈë:\nName-FaxNo."},
    {IDS_GAMP_LENGTHTOOLONG,  "Ì«éLÁË."},
    {IDS_GAMP_NOFOUNDDATA,    "›]Óаl¬FÆ¥ÅäµÄí—Ä¿."},
    {IDS_GAMP_USERID,         "ÓÑôIDÌ–"},
    {IDS_GAMP_PASSWORD,       "ÓÑô¿ÚÁî"},
    {IDS_GAMP_EMAILADDRESS,   "»Ø‘ªEmailµØÖ·"},
    {IDS_GAMP_GATEWAY,        "¾WêPEmailµØÖ·"},
    {IDS_GAMP_SERVER,         "SMTP ·þ„ÕÆ÷"},
    {IDS_GAMP_PORT,           "SMTP ¶Ë¿Ú"},
    {IDS_GAMP_FAXNAME,        "‚÷Õæ™CÆ÷Ãû"},
    {IDS_GAMP_SYSCONFIG,      "ϵ½yÔOÖÃ"},
    {IDS_GAMP_INVALIDVALUE,   " ŸoЧµÄ”µ“þ."},
    {IDS_GAMP_BETWEEN9999,    " ±ØíšÏÞÖÆÔÚ1-9999."},
    {IDS_GAMP_OPENFILEERROR,  "´òé_Îļþ•r³öåe."},
    {IDS_GAMP_FAILTOOLBAR,    "„“½¨¹¤¾ß—l•r³öåe."},
    {IDS_GAMP_SETSYSCONFIGFIRST, "ÕˆÏÈÔOÖÃϵ½y…¢”µ."},
{IDS_STATUS_SMTPFROM,     "°lËÍ SMTP from µØÖ·"},
    {IDS_STATUS_SMTPTO,       "°lËÍ SMTP to µØÖ·"},
    {IDS_STATUS_TRANSFERING,  "‚÷Ý”ÕýÎÄ”µ“þ..."},
    {IDS_STATUS_GETPORT,      "™zË÷ TCP/IP ¾W½j¶Ë¿Ú..."},
    {IDS_STATUS_RETRIVEADDRESS, "™zË÷ internet µØÖ·..."},
    {IDS_STATUS_GETPROTOCOL,  "™zË÷¾W½j…f×h..."},
    {IDS_STATUS_CREATESOCKET, "„“½¨ socket..."},
    {IDS_STATUS_ESTABLISHCONNECT, "½¨Á¢¾W½jßB½Ó..."},
    {IDS_STATUS_GETHOSTNAME,  "™zË÷Ö÷™CÃû·Q..."},
    {IDS_STATUS_CONNECTTOTCP, "Åc TCP ½¨Á¢ßB½Ó..."},
    {IDS_STATUS_SENDHELO,     "°lËÍ HELO ÐÅÏ¢..."},
    {IDS_STATUS_REPLYHELO,    "½ÓÊÕ HELO µÄ»Ø‘ª..."},
    {IDS_STATUS_LASTTASK,     "×îááµÄÈ΄Õ..."},
    {IDS_STATUS_TRANFORMOK,   "¾W½j‚÷Ý”³É¹¦."},
    {IDS_STATUS_TRANSFORMERROR, "¾W½j‚÷ݔʧ”¡."},
    {IDS_GAMP_READG3ERROR,    "×x .g3 Îļþ•r³öåe£¬¿ÉÄÜËü²»ÊÇÕý´_µÄ¸ñʽ."},
{IDS_GAMP_FIRSTPAGE,      "ËüÒѽ›ÊǵÚÒ»í“ÁË."},
    {IDS_GAMP_LASTPAGE,       "ËüÒѽ›ÊÇ×îááÒ»í“ÁË."},
    {IDS_GAMP_PAGE,           "í“Ì–"},
    {IDS_GAMP_THREADLIST,     "ß\ÐеĂ÷Ý”¾€³Ì"},
    {IDS_GAMP_CURSTATUS,      "®”Ç° î‘B"},
    {IDS_GAMP_TERMINATE,      "½KÖ¹"},
    {IDS_GAMP_MEMORYERROR,    "ƒÈ´æ³ö¬F‡ÀÖØåeÕ`!"},
{0,NULL}
};

///////////////////////////////////////////
////////language text item pointer/////////
LANG_POINTER langPointer[]={
{MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),&usaTextItem[0]},
{MAKELANGID(LANG_CHINESE,SUBLANG_CHINESE_SIMPLIFIED),&chsTextItem[0]},
{MAKELANGID(LANG_CHINESE,SUBLANG_CHINESE_TRADITIONAL),&twnTextItem[0]},
{0,NULL}
};

void SetCurrentLanguage(WORD langID)
{
int i=0;
while(1){
if(langPointer[i].langID==0){
gCurrentIndex=0;//English default even if error occurred
return;
}
if(langPointer[i].langID==langID)
break;
i++;
}
gCurrentIndex=i;
}

WORD GetCurrentLanguage()
{
return langPointer[gCurrentIndex].langID;
}

int  LoadTextByID(UINT resID,LPTSTR string,int maxsize)
{
if(maxsize<=0)
return maxsize;

CString     str;
LPTEXT_ITEM lpItem;
int         copylength;

copylength=0;

if(gCurrentIndex==0){//English
str.LoadString(resID);
copylength=min(str.GetLength(),maxsize-1);
lstrcpy(string,str);
}
else{
lpItem=langPointer[gCurrentIndex].lpTextItem;
while(1){
if(lpItem->resID==0)
break;//it will never occur
if(lpItem->resID==resID){
copylength=min(lstrlen(lpItem->text),maxsize-1);
lstrcpy(string,lpItem->text);
break;
}
lpItem++;
}
}
return copylength;
};

#3


谢谢,有没有简单一点的方法?如果我还要换位图(对话框资源内),代码量应该比较大的。。。20分奉上。

#1


你可以为每一种语言建立一个资源动态库,在运行过程中根据不同的选择动态装入合适的动态库,并且所有的界面元素都从这个动态库中装入就行了——上面不应该有问题吧

#2


我刚完成一个国际化的网络应用程序,我是这样做的.
1:思路,UI的国际化分为两个部分,菜单和其它资源.
2:国际化的工作也就分为两个部分,菜单资源的ReLoad和其它UI(文本)的Reload.
3:菜单的ReLoad使用下面的函数(我的风格尽量不用MFC),菜单可以直接在资源文件.rc
中编辑.
BOOL ChangeMenu()
{
//////////////////////////////////////////////
//////It's difficult to change the menu///////
/////It's important to set m_hMenuDefault/////
/////to hNewMenu.First,I haven't do this,/////
/////error will occur whenever the window/////
/////be closed.The reason is,memory address///
////will change if HMENU changed.Yet,I can////
///////not find any information about ////////
///////m_hMenuDefault in Help document////////

HINSTANCE     hInst;
HRSRC         hRc;
HGLOBAL       hGl;
WORD          lang;
MENUTEMPLATE* lpTemp;
HMENU         hOldMenu,hNewMenu;

lang=GetCurrentLanguage();
hInst=AfxGetResourceHandle();
hRc=::FindResourceEx(hInst,RT_MENU,
MAKEINTRESOURCE(IDR_MAINFRAME),lang);
if(hRc==NULL)
return FALSE;
hGl=::LoadResource(hInst,hRc);
if(hGl==NULL)
return FALSE;
lpTemp=(MENUTEMPLATE *)::LockResource(hGl);
if(lpTemp==NULL){
::FreeResource(hGl);
return FALSE;
}
hNewMenu=::LoadMenuIndirect(lpTemp);
if(hNewMenu==NULL){
::FreeResource(hGl);
::UnlockResource(hGl);
return FALSE;
}
hOldMenu=::GetMenu(m_hWnd);
if(hOldMenu)
::DestroyMenu(hOldMenu);
::SetMenu(m_hWnd,hNewMenu);
m_hMenuDefault=hNewMenu;
::FreeResource(hGl);
::UnlockResource(hGl);
return TRUE;
}
4:其它资源的Reload基于下面的思路:在资源文件.rc中全是英文资源,在textres.*文件中实现资源的Reload,看了下面的两个文件你应该会明白.
*****************textres.h****************************
#ifndef _TEXTRES_H
#define _TEXTRES_H

#include "resource.h"

typedef struct _text_item
{
UINT    resID;
LPCTSTR text;
} TEXT_ITEM,FAR* LPTEXT_ITEM;

typedef struct _lang_pointer
{
WORD        langID;
LPTEXT_ITEM lpTextItem;
} LANG_POINTER,FAR* LPLANG_POINTER;

void SetCurrentLanguage(WORD langID);
WORD GetCurrentLanguage();

int  LoadTextByID(UINT resID,LPTSTR string,int maxsize);
//maxsize should include the terminating null character

#endif

*************************************************************
#include "StdAfx.h"
#include "textres.h"

int gCurrentIndex;

//////////////////////////////
/////English Text Resource////
////Retrieve from .rc file////
TEXT_ITEM usaTextItem[]={
{0,NULL}
};

///////////////////////////////////
////Chinese Simplified Resource////
///////Retrive until resID==0//////
TEXT_ITEM chsTextItem[]={
{IDS_GAMP_APPTITLE,       "MailToFax 1.0"},
{IDS_FILTER,              "&acute;&laquo;&Otilde;&aelig;&Icirc;&Auml;&frac14;&thorn;|*.g3|&Euml;ù&Oacute;&ETH;&Icirc;&Auml;&frac14;&thorn;|*.*|"},
{IDS_GAMP_BROWSE,         "&auml;&macr;&Agrave;&Agrave;"},
    {IDS_GAMP_NAMEANDFAX,     "&Atilde;&ucirc;&sup3;&AElig;&ordm;&Iacute;&acute;&laquo;&Otilde;&aelig;&ordm;&Aring;:"},
    {IDS_GAMP_SUBJECT,        "&Ouml;÷&Igrave;&acirc;"},
    {IDS_GAMP_SEND,           "·&cent;&Euml;&Iacute;"},
{IDS_GAMP_FILENAME,       "&Icirc;&Auml;&frac14;&thorn;&Atilde;&ucirc;&sup3;&AElig;:"},
    {IDS_GAMP_COMMBOOK,       "&Iacute;¨&Ntilde;&para;&sup2;&frac34;"},
    {IDS_GAMP_OK,             "&Egrave;·&para;¨"},
    {IDS_GAMP_CANCEL,         "&Egrave;&iexcl;&Iuml;&ucirc;"},
    {IDS_GAMP_NEW,            "&ETH;&Acirc;&Ocirc;&ouml;"},
    {IDS_GAMP_MODIFY,         "&ETH;&THORN;&cedil;&Auml;"},
{IDS_GAMP_DELETE,         "&Eacute;&frac34;&sup3;&yacute;"},
    {IDS_GAMP_NAME,           "&ETH;&Otilde;&Atilde;&ucirc;"},
    {IDS_GAMP_FAXNO,          "&acute;&laquo;&Otilde;&aelig;&ordm;&Aring;"},
    {IDS_GAMP_COMPANY,        "&sup1;&laquo;&Euml;&frac34;"},
    {IDS_GAMP_CANNOTBEEMPTY,  " &sup2;&raquo;&Auml;&Uuml;&Icirc;&ordf;&iquest;&Otilde;."},
    {IDS_GAMP_MUSTBENUMERIC,  " ±&Oslash;&ETH;&euml;&Ecirc;&Ccedil;&Ecirc;&yacute;×&Ouml;."},
    {IDS_GAMP_CANNOTBEZERO,   " &sup2;&raquo;&Auml;&Uuml;&Icirc;&ordf;&Aacute;&atilde;."},
    {IDS_GAMP_NODATAREMAINED, "&Ograve;&Ntilde;&frac34;&shy;&Atilde;&raquo;&Oacute;&ETH;&Ecirc;&yacute;&frac34;&Yacute;&Aacute;&Euml;."},
    {IDS_GAMP_NOROWSELECTED,  "&Ccedil;&euml;&Iuml;&Egrave;&Ntilde;&iexcl;&Ocirc;&ntilde;&Ograve;&raquo;&ETH;&ETH;&Ecirc;&yacute;&frac34;&Yacute;."},
    {IDS_GAMP_DATABASEERROR,  "&Ecirc;&yacute;&frac34;&Yacute;&iquest;&acirc;·&Atilde;&Icirc;&Ecirc;&sup3;&ouml;&acute;í."},
    {IDS_GAMP_DATAEXIST,      "&Ecirc;&yacute;&frac34;&Yacute;&Ograve;&Ntilde;&frac34;&shy;&acute;&aelig;&Ocirc;&Uacute;."},
    {IDS_GAMP_ORIGCOPY,       "&Ccedil;&euml;&sup1;&ordm;&Acirc;ò&Otilde;&yacute;°&aelig;&Egrave;í&frac14;&thorn;."},
    {IDS_GAMP_FINDBY,         "&Igrave;&otilde;&frac14;&thorn;&sup2;é&Ntilde;&macr;"},
    {IDS_GAMP_QUERY,          "&sup2;é&Ntilde;&macr;"},
    {IDS_GAMP_SELECTED,       "&Ograve;&Ntilde;&frac34;&shy;&Ntilde;&iexcl;&Ocirc;&ntilde;"},
    {IDS_GAMP_NEXT,           "&Iuml;&Acirc;&Ograve;&raquo;&Iuml;&icirc;"},
{IDS_GAMP_NAMEFAXNONOTMATCH, "±&Oslash;&ETH;&euml;°&acute;&acute;&Euml;&cedil;&ntilde;&Ecirc;&frac12;&Ecirc;&auml;&Egrave;&euml;:\nName-FaxNo."},
    {IDS_GAMP_LENGTHTOOLONG,  "&Igrave;&laquo;&sup3;¤&Aacute;&Euml;."},
    {IDS_GAMP_NOFOUNDDATA,    "&Atilde;&raquo;&Oacute;&ETH;·&cent;&Iuml;&Ouml;&AElig;&yen;&Aring;&auml;&micro;&Auml;&Iuml;&icirc;&Auml;&iquest;."},
    {IDS_GAMP_USERID,         "&Oacute;&Atilde;&raquo;§ID&ordm;&Aring;"},
    {IDS_GAMP_PASSWORD,       "&Oacute;&Atilde;&raquo;§&iquest;&Uacute;&Aacute;&icirc;"},
    {IDS_GAMP_EMAILADDRESS,   "&raquo;&Oslash;&Oacute;&brvbar;Email&micro;&Oslash;&Ouml;·"},
    {IDS_GAMP_GATEWAY,        "&Iacute;&oslash;&sup1;&Oslash;Email&micro;&Oslash;&Ouml;·"},
    {IDS_GAMP_SERVER,         "SMTP ·&thorn;&Icirc;&ntilde;&AElig;÷"},
    {IDS_GAMP_PORT,           "SMTP &para;&Euml;&iquest;&Uacute;"},
    {IDS_GAMP_FAXNAME,        "&acute;&laquo;&Otilde;&aelig;&raquo;ú&AElig;÷&Atilde;&ucirc;"},
    {IDS_GAMP_SYSCONFIG,      "&Iuml;&micro;&Iacute;&sup3;&Eacute;è&Ouml;&Atilde;"},
    {IDS_GAMP_INVALIDVALUE,   " &Icirc;&THORN;&ETH;§&micro;&Auml;&Ecirc;&yacute;&frac34;&Yacute;."},
    {IDS_GAMP_BETWEEN9999,    " ±&Oslash;&ETH;&euml;&Iuml;&THORN;&Ouml;&AElig;&Ocirc;&Uacute;1-9999."},
    {IDS_GAMP_OPENFILEERROR,  "&acute;ò&iquest;&ordf;&Icirc;&Auml;&frac14;&thorn;&Ecirc;±&sup3;&ouml;&acute;í."},
    {IDS_GAMP_FAILTOOLBAR,    "&acute;&acute;&frac12;¨&sup1;¤&frac34;&szlig;&Igrave;&otilde;&Ecirc;±&sup3;&ouml;&acute;í."},
    {IDS_GAMP_SETSYSCONFIGFIRST, "&Ccedil;&euml;&Iuml;&Egrave;&Eacute;è&Ouml;&Atilde;&Iuml;&micro;&Iacute;&sup3;&sup2;&Icirc;&Ecirc;&yacute;."},
{IDS_STATUS_SMTPFROM,     "·&cent;&Euml;&Iacute; SMTP from &micro;&Oslash;&Ouml;·"},
    {IDS_STATUS_SMTPTO,       "·&cent;&Euml;&Iacute; SMTP to &micro;&Oslash;&Ouml;·"},
    {IDS_STATUS_TRANSFERING,  "&acute;&laquo;&Ecirc;&auml;&Otilde;&yacute;&Icirc;&Auml;&Ecirc;&yacute;&frac34;&Yacute;..."},
    {IDS_STATUS_GETPORT,      "&frac14;ì&Euml;÷ TCP/IP &Iacute;&oslash;&Acirc;&ccedil;&para;&Euml;&iquest;&Uacute;..."},
    {IDS_STATUS_RETRIVEADDRESS, "&frac14;ì&Euml;÷ internet &micro;&Oslash;&Ouml;·..."},
    {IDS_STATUS_GETPROTOCOL,  "&frac14;ì&Euml;÷&Iacute;&oslash;&Acirc;&ccedil;&ETH;&shy;&Ograve;é..."},
    {IDS_STATUS_CREATESOCKET, "&acute;&acute;&frac12;¨ socket..."},
    {IDS_STATUS_ESTABLISHCONNECT, "&frac12;¨&Aacute;&cent;&Iacute;&oslash;&Acirc;&ccedil;&Aacute;&not;&frac12;&Oacute;..."},
    {IDS_STATUS_GETHOSTNAME,  "&frac14;ì&Euml;÷&Ouml;÷&raquo;ú&Atilde;&ucirc;&sup3;&AElig;..."},
    {IDS_STATUS_CONNECTTOTCP, "&Oacute;&euml; TCP &frac12;¨&Aacute;&cent;&Aacute;&not;&frac12;&Oacute;..."},
    {IDS_STATUS_SENDHELO,     "·&cent;&Euml;&Iacute; HELO &ETH;&Aring;&Iuml;&cent;..."},
    {IDS_STATUS_REPLYHELO,    "&frac12;&Oacute;&Ecirc;&Otilde; HELO &micro;&Auml;&raquo;&Oslash;&Oacute;&brvbar;..."},
    {IDS_STATUS_LASTTASK,     "×&icirc;&ordm;ó&micro;&Auml;&Egrave;&Icirc;&Icirc;&ntilde;..."},
    {IDS_STATUS_TRANFORMOK,   "&Iacute;&oslash;&Acirc;&ccedil;&acute;&laquo;&Ecirc;&auml;&sup3;&Eacute;&sup1;&brvbar;."},
    {IDS_STATUS_TRANSFORMERROR, "&Iacute;&oslash;&Acirc;&ccedil;&acute;&laquo;&Ecirc;&auml;&Ecirc;§°&Uuml;."},
    {IDS_GAMP_READG3ERROR,    "&para;&Aacute; .g3 &Icirc;&Auml;&frac14;&thorn;&Ecirc;±&sup3;&ouml;&acute;í&pound;&not;&iquest;&Eacute;&Auml;&Uuml;&Euml;ü&sup2;&raquo;&Ecirc;&Ccedil;&Otilde;&yacute;&Egrave;·&micro;&Auml;&cedil;&ntilde;&Ecirc;&frac12;."},
{IDS_GAMP_FIRSTPAGE,      "&Euml;ü&Ograve;&Ntilde;&frac34;&shy;&Ecirc;&Ccedil;&micro;&Uacute;&Ograve;&raquo;&Ograve;&sup3;&Aacute;&Euml;."},
    {IDS_GAMP_LASTPAGE,       "&Euml;ü&Ograve;&Ntilde;&frac34;&shy;&Ecirc;&Ccedil;×&icirc;&ordm;ó&Ograve;&raquo;&Ograve;&sup3;&Aacute;&Euml;."},
    {IDS_GAMP_PAGE,           "&Ograve;&sup3;&ordm;&Aring;"},
    {IDS_GAMP_THREADLIST,     "&Ocirc;&Euml;&ETH;&ETH;&micro;&Auml;&acute;&laquo;&Ecirc;&auml;&Iuml;&szlig;&sup3;&Igrave;"},
    {IDS_GAMP_CURSTATUS,      "&micro;±&Ccedil;°×&acute;&Igrave;&not;"},
    {IDS_GAMP_TERMINATE,      "&Ouml;&Otilde;&Ouml;&sup1;"},
    {IDS_GAMP_MEMORYERROR,    "&Auml;&Uacute;&acute;&aelig;&sup3;&ouml;&Iuml;&Ouml;&Ntilde;&Iuml;&Ouml;&Oslash;&acute;í&Icirc;ó!"},
{0,NULL}
};

///////////////////////////////////
///Chinese Traditional Resource////
///////Retrive until resID==0//////
TEXT_ITEM twnTextItem[]={
{IDS_GAMP_APPTITLE,       "MailToFax 1.0"},
{IDS_FILTER,              "&#8218;÷&Otilde;&aelig;&Icirc;&Auml;&frac14;&thorn;|*.g3|&Euml;ù&Oacute;&ETH;&Icirc;&Auml;&frac14;&thorn;|*.*|"},
{IDS_GAMP_BROWSE,         "&#382;g&Oacute;["},
    {IDS_GAMP_NAMEANDFAX,     "&Atilde;&ucirc;·Q&ordm;&Iacute;&#8218;÷&Otilde;&aelig;&Igrave;–:"},
    {IDS_GAMP_SUBJECT,        "&Ouml;÷&icirc;}"},
    {IDS_GAMP_SEND,           "°l&Euml;&Iacute;"},
{IDS_GAMP_FILENAME,       "&Icirc;&Auml;&frac14;&thorn;&Atilde;&ucirc;·Q:"},
    {IDS_GAMP_COMMBOOK,       "&Iacute;¨&Oacute;&#141;&sup2;&frac34;"},
    {IDS_GAMP_OK,             "&acute;_&para;¨"},
    {IDS_GAMP_CANCEL,         "&Egrave;&iexcl;&Iuml;&ucirc;"},
    {IDS_GAMP_NEW,            "&ETH;&Acirc;&Ocirc;&ouml;"},
    {IDS_GAMP_MODIFY,         "&ETH;&THORN;&cedil;&Auml;"},
{IDS_GAMP_DELETE,         "&#8222;h&sup3;&yacute;"},
    {IDS_GAMP_NAME,           "&ETH;&Otilde;&Atilde;&ucirc;"},
    {IDS_GAMP_FAXNO,          "&#8218;÷&Otilde;&aelig;&Igrave;–"},
    {IDS_GAMP_COMPANY,        "&sup1;&laquo;&Euml;&frac34;"},
    {IDS_GAMP_CANNOTBEEMPTY,  " &sup2;&raquo;&Auml;&Uuml;&nbsp;‘&iquest;&Otilde;."},
    {IDS_GAMP_MUSTBENUMERIC,  " ±&Oslash;í&#353;&Ecirc;&Ccedil;”&micro;×&Ouml;."},
    {IDS_GAMP_CANNOTBEZERO,   " &sup2;&raquo;&Auml;&Uuml;&nbsp;‘&Aacute;&atilde;."},
    {IDS_GAMP_NODATAREMAINED, "&Ograve;&Ntilde;&frac12;&#8250;&#8250;]&Oacute;&ETH;”&micro;“&thorn;&Aacute;&Euml;."},
    {IDS_GAMP_NOROWSELECTED,  "&Otilde;&#710;&Iuml;&Egrave;&szlig;x“&ntilde;&Ograve;&raquo;&ETH;&ETH;”&micro;“&thorn;."},
    {IDS_GAMP_DATABASEERROR,  "”&micro;“&thorn;&#381;ì&Ocirc;L&#8224;–&sup3;&ouml;&aring;e."},
    {IDS_GAMP_DATAEXIST,      "”&micro;“&thorn;&Ograve;&Ntilde;&frac12;&#8250;&acute;&aelig;&Ocirc;&Uacute;."},
    {IDS_GAMP_ORIGCOPY,       "&Otilde;&#710;&Ugrave;&#143;&Ugrave;I&Otilde;&yacute;°&aelig;&Uuml;&#8250;&frac14;&thorn;."},
    {IDS_GAMP_FINDBY,         "—l&frac14;&thorn;&sup2;é&Ocirc;&#402;"},
    {IDS_GAMP_QUERY,          "&sup2;é&Ocirc;&#402;"},
    {IDS_GAMP_SELECTED,       "&Ograve;&Ntilde;&frac12;&#8250;&szlig;x“&ntilde;"},
    {IDS_GAMP_NEXT,           "&Iuml;&Acirc;&Ograve;&raquo;í—"},
{IDS_GAMP_NAMEFAXNONOTMATCH, "±&Oslash;í&#353;°&acute;&acute;&Euml;&cedil;&ntilde;&Ecirc;&frac12;&Yacute;”&Egrave;&euml;:\nName-FaxNo."},
    {IDS_GAMP_LENGTHTOOLONG,  "&Igrave;&laquo;éL&Aacute;&Euml;."},
    {IDS_GAMP_NOFOUNDDATA,    "&#8250;]&Oacute;&ETH;°l&not;F&AElig;&yen;&Aring;&auml;&micro;&Auml;í—&Auml;&iquest;."},
    {IDS_GAMP_USERID,         "&Oacute;&Atilde;‘&ocirc;ID&Igrave;–"},
    {IDS_GAMP_PASSWORD,       "&Oacute;&Atilde;‘&ocirc;&iquest;&Uacute;&Aacute;&icirc;"},
    {IDS_GAMP_EMAILADDRESS,   "&raquo;&Oslash;‘&ordf;Email&micro;&Oslash;&Ouml;·"},
    {IDS_GAMP_GATEWAY,        "&frac34;WêPEmail&micro;&Oslash;&Ouml;·"},
    {IDS_GAMP_SERVER,         "SMTP ·&thorn;&#8222;&Otilde;&AElig;÷"},
    {IDS_GAMP_PORT,           "SMTP &para;&Euml;&iquest;&Uacute;"},
    {IDS_GAMP_FAXNAME,        "&#8218;÷&Otilde;&aelig;&#8482;C&AElig;÷&Atilde;&ucirc;"},
    {IDS_GAMP_SYSCONFIG,      "&Iuml;&micro;&frac12;y&Ocirc;O&Ouml;&Atilde;"},
    {IDS_GAMP_INVALIDVALUE,   " &#376;o&ETH;§&micro;&Auml;”&micro;“&thorn;."},
    {IDS_GAMP_BETWEEN9999,    " ±&Oslash;í&#353;&Iuml;&THORN;&Ouml;&AElig;&Ocirc;&Uacute;1-9999."},
    {IDS_GAMP_OPENFILEERROR,  "&acute;òé_&Icirc;&Auml;&frac14;&thorn;&#8226;r&sup3;&ouml;&aring;e."},
    {IDS_GAMP_FAILTOOLBAR,    "&#8222;“&frac12;¨&sup1;¤&frac34;&szlig;—l&#8226;r&sup3;&ouml;&aring;e."},
    {IDS_GAMP_SETSYSCONFIGFIRST, "&Otilde;&#710;&Iuml;&Egrave;&Ocirc;O&Ouml;&Atilde;&Iuml;&micro;&frac12;y…&cent;”&micro;."},
{IDS_STATUS_SMTPFROM,     "°l&Euml;&Iacute; SMTP from &micro;&Oslash;&Ouml;·"},
    {IDS_STATUS_SMTPTO,       "°l&Euml;&Iacute; SMTP to &micro;&Oslash;&Ouml;·"},
    {IDS_STATUS_TRANSFERING,  "&#8218;÷&Yacute;”&Otilde;&yacute;&Icirc;&Auml;”&micro;“&thorn;..."},
    {IDS_STATUS_GETPORT,      "&#8482;z&Euml;÷ TCP/IP &frac34;W&frac12;j&para;&Euml;&iquest;&Uacute;..."},
    {IDS_STATUS_RETRIVEADDRESS, "&#8482;z&Euml;÷ internet &micro;&Oslash;&Ouml;·..."},
    {IDS_STATUS_GETPROTOCOL,  "&#8482;z&Euml;÷&frac34;W&frac12;j…f×h..."},
    {IDS_STATUS_CREATESOCKET, "&#8222;“&frac12;¨ socket..."},
    {IDS_STATUS_ESTABLISHCONNECT, "&frac12;¨&Aacute;&cent;&frac34;W&frac12;j&szlig;B&frac12;&Oacute;..."},
    {IDS_STATUS_GETHOSTNAME,  "&#8482;z&Euml;÷&Ouml;÷&#8482;C&Atilde;&ucirc;·Q..."},
    {IDS_STATUS_CONNECTTOTCP, "&Aring;c TCP &frac12;¨&Aacute;&cent;&szlig;B&frac12;&Oacute;..."},
    {IDS_STATUS_SENDHELO,     "°l&Euml;&Iacute; HELO &ETH;&Aring;&Iuml;&cent;..."},
    {IDS_STATUS_REPLYHELO,    "&frac12;&Oacute;&Ecirc;&Otilde; HELO &micro;&Auml;&raquo;&Oslash;‘&ordf;..."},
    {IDS_STATUS_LASTTASK,     "×&icirc;áá&micro;&Auml;&Egrave;&Icirc;&#8222;&Otilde;..."},
    {IDS_STATUS_TRANFORMOK,   "&frac34;W&frac12;j&#8218;÷&Yacute;”&sup3;&Eacute;&sup1;&brvbar;."},
    {IDS_STATUS_TRANSFORMERROR, "&frac34;W&frac12;j&#8218;÷&Yacute;”&Ecirc;§”&iexcl;."},
    {IDS_GAMP_READG3ERROR,    "×x .g3 &Icirc;&Auml;&frac14;&thorn;&#8226;r&sup3;&ouml;&aring;e&pound;&not;&iquest;&Eacute;&Auml;&Uuml;&Euml;ü&sup2;&raquo;&Ecirc;&Ccedil;&Otilde;&yacute;&acute;_&micro;&Auml;&cedil;&ntilde;&Ecirc;&frac12;."},
{IDS_GAMP_FIRSTPAGE,      "&Euml;ü&Ograve;&Ntilde;&frac12;&#8250;&Ecirc;&Ccedil;&micro;&Uacute;&Ograve;&raquo;í“&Aacute;&Euml;."},
    {IDS_GAMP_LASTPAGE,       "&Euml;ü&Ograve;&Ntilde;&frac12;&#8250;&Ecirc;&Ccedil;×&icirc;áá&Ograve;&raquo;í“&Aacute;&Euml;."},
    {IDS_GAMP_PAGE,           "í“&Igrave;–"},
    {IDS_GAMP_THREADLIST,     "&szlig;\&ETH;&ETH;&micro;&Auml;&#8218;÷&Yacute;”&frac34;&#8364;&sup3;&Igrave;"},
    {IDS_GAMP_CURSTATUS,      "&reg;”&Ccedil;°&nbsp;&icirc;‘B"},
    {IDS_GAMP_TERMINATE,      "&frac12;K&Ouml;&sup1;"},
    {IDS_GAMP_MEMORYERROR,    "&#402;&Egrave;&acute;&aelig;&sup3;&ouml;&not;F&#8225;&Agrave;&Ouml;&Oslash;&aring;e&Otilde;`!"},
{0,NULL}
};

///////////////////////////////////////////
////////language text item pointer/////////
LANG_POINTER langPointer[]={
{MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),&usaTextItem[0]},
{MAKELANGID(LANG_CHINESE,SUBLANG_CHINESE_SIMPLIFIED),&chsTextItem[0]},
{MAKELANGID(LANG_CHINESE,SUBLANG_CHINESE_TRADITIONAL),&twnTextItem[0]},
{0,NULL}
};

void SetCurrentLanguage(WORD langID)
{
int i=0;
while(1){
if(langPointer[i].langID==0){
gCurrentIndex=0;//English default even if error occurred
return;
}
if(langPointer[i].langID==langID)
break;
i++;
}
gCurrentIndex=i;
}

WORD GetCurrentLanguage()
{
return langPointer[gCurrentIndex].langID;
}

int  LoadTextByID(UINT resID,LPTSTR string,int maxsize)
{
if(maxsize<=0)
return maxsize;

CString     str;
LPTEXT_ITEM lpItem;
int         copylength;

copylength=0;

if(gCurrentIndex==0){//English
str.LoadString(resID);
copylength=min(str.GetLength(),maxsize-1);
lstrcpy(string,str);
}
else{
lpItem=langPointer[gCurrentIndex].lpTextItem;
while(1){
if(lpItem->resID==0)
break;//it will never occur
if(lpItem->resID==resID){
copylength=min(lstrlen(lpItem->text),maxsize-1);
lstrcpy(string,lpItem->text);
break;
}
lpItem++;
}
}
return copylength;
};

#3


谢谢,有没有简单一点的方法?如果我还要换位图(对话框资源内),代码量应该比较大的。。。20分奉上。