正好搜了点资料,看看对你是否有用 xtreme的完全汉化指南! 通过一些网友关于汉化Xtreme Toolkit问题的讨论,以及本人的实践和摸索,现将汉化方法公布如下,请放心,绝对可以成功!(一)Xtreme库文件汉化: 1、将Include/L.cn下的XTResource.rc复制到Include目录下,替换原先的文件,由于该中文资源文件的汉化不是十分彻底,你可以自己把该文件中其余的英文翻译为中文; 2、在VC中打开XTToolkit_Dll\XTToolkit_Dll.dsw工程文件,现在你可以打开ResourceView观察汉化后的对话框和字符串; 3、如果现在你编译的话,会发现资源文件编译错误,这是因为你还没有设定合适的字符编码,不过有些朋友运气好的话,可能仍然可以通过编译,但在运行会发生乱码现象,因此,设定资源的字符编码是必须的。通过菜单【View->Resource Includes...】,修改“Compile-time directives:”框中的内容: LANGUAGE 4, 2 #pragma code_page(936) 4、OK!可以编译了,不过别忘了打开Build工具栏,选择不同的编译模式哦!注 :在汉化的同时,你可以修改src/XTGlobal.cpp文件,这个文件里面有一个Bug,不过它只对Debug模式编译的文件敏感,修改如下:// if ( ( lfHorz.lfCharSet & SYMBOL_CHARSET ) == 0 ) // line 274 if ( ( lfHorz.lfCharSet & DEFAULT_CHARSET ) == 0 ) (二)向导的汉化 1、打开工程文件XTAppWizard_v6\XTAppWizard.dsw;(我用的VC6) 2、修改文件XTAppWizardAw.cpp,如下:// This is called immediately after the custom AppWizard is loaded. Initialize // the state of the custom AppWizard here. void CXTAppWizardAppWiz::InitCustomAppWiz() { // Create a new dialog chooser; CDialogChooser's constructor initializes // its internal array with pointers to the steps. m_pChooser = new CDialogChooser;// At first, we don't know the total number of steps, since there are two // possible "tracks" (MDI/SDI app and dialog-based app). SetNumberOfSteps(-1);// Inform AppWizard of the languages we support //SetSupportedLanguages(_T("German [Standard] (APPWZDEU.DLL);0x40704b0\nEnglish [United States] (APPWZENU.DLL);0x40904b0\nSpanish [International Sort] (APPWZESP.DLL);0xc0a04b0\nFrench [Standard] (APPWZFRA.DLL);0x40c04b0\nItalian [Standard] (APPWZITA.DLL);0x41004b0")); SetSupportedLanguages(_T("中文 [中国] (APPWZCHS.DLL);0x80404b0\nEnglish [United States] (APPWZENU.DLL);0x40904b0\nSpanish [International Sort] (APPWZESP.DLL);0xc0a04b0\nFrench [Standard] (APPWZFRA.DLL);0x40c04b0\nItalian [Standard] (APPWZITA.DLL);0x41004b0")); //----------------------------------------------------------------------- // Initial settings for the standard control bar class. //----------------------------------------------------------------------- .......... ........ 2、OK,你可以编译了,生成的XTAppWizard_vc6.awx文件将自动复制为(MSDEVDIR)\Template\XTAppWizard.awx; 3、运行向导时请选择中文资源。 注 :你可以对Wizard的对话框资源进行汉化,不过这仅仅是向导的界面汉化,对于向导的运行结果没有半点影响。Xtreme ToolKit 字体说明 根据 Xtreme ToolKit 帮助的说明,如果需要设置 Xtreme ToolKit 的字体,可以在 app 类的 InitInstance 函数中做如下的代码 // get the log font currently used by the toolkit XT_LOGFONT lf; xtAfxData.font.GetLogFont( &lf );// change the font to Verdana _tcscpy( lf.lfFaceName, _T( "Verdana" ) );// set the font used by the toolkit. CFont font; font.CreateFontIndirect( &lf ); xtAfxData.SetGlobalFont( &font ); // 这句会 ASSERT 失败但在具体的使用中,因为通常要将字体改为宋体 9 号,这样做会在 Debug 模式下 ASSERT 失败(VC7,VC6 没试),原因是 CFont 在 Attach 时未 Detach,所以应该上述代码前增加一句,如: font.CreateFontIndirect( &lf ); xtAfxData.FreeSysFonts(); // 先 Free 掉以前的资源 xtAfxData.SetGlobalFont( &font ); 这样就可以了, 但在随后的调用中,如果需要使用垂直字体时,如 CXTToolBar 还会有 ASSERT 失败,所以,最好是使用以下的代码:// get the log font currently used by the toolkit XT_LOGFONT lf; xtAfxData.font.GetLogFont( &lf );// change the font to Verdana lf.lfHeight = 12; lf.lfWidth = 0; lf.lfCharSet = GB2312_CHARSET;// 正常字体 _tcscpy( lf.lfFaceName, _T( "宋体" ) ); CFont font; font.CreateFontIndirect( &lf);// 垂直字体 CFont vfont; _tcscpy( lf.lfFaceName, _T( "@宋体" ) ); vfont.CreateFontIndirect( &lf);// set the font used by the toolkit. xtAfxData.FreeSysFonts(); xtAfxData.SetGlobalFont(&font, &vfont);这样做的结果是你的应用程序更象一个标准的中文软件。 XT 中 DocBar 的 Caption 的字体 因为 CXTDockWindow 的基类 CXTControlBar 使用了 8pt 固定字体,所以比通常的字体小 void CXTControlBar::UpdateControlBarFonts() { ... int iHeight = -::MulDiv(8, ::GetDeviceCaps(dc.m_hDC, LOGPIXELSY), 72); // 在此处固定 .... lf.lfHeight = iHeight; m_font.CreateFontIndirect(&lf); ....... } 导致 DocBar 在停靠时的 Caption 比较难看,针对以上问题 一 可以在运行时,在 ControlBar 的派生类中重新为 m_font 等赋于指定大小的字体,这种方法我以前尝试没有成功,虽然理论上好象没有问题,我是在 OnCreate 函数中做这件事的。二 修改 CXTControlBar::UpdateControlBarFonts() ,将上边的的实现修改成 void CXTControlBar::UpdateControlBarFonts() { ... int iHeight = -::MulDiv(9, ::GetDeviceCaps(dc.m_hDC, LOGPIXELSY), 72); // 在此处固定,由 8 号字增为 9 号字 .... lf.lfHeight = iHeight; m_font.CreateFontIndirect(&lf); ....... } 然后重新编译 DLL 即可,这样做成功了。 尽管对于中文的系统来说,第二种做法也算基本可行,但我想知道第一种方法为什么不行,有尝试过的朋友请跟贴讨论。
应该也可以使用的吧帮助里面建议用相应语言rc文件替换*.rc文件。
xtreme的完全汉化指南!
通过一些网友关于汉化Xtreme Toolkit问题的讨论,以及本人的实践和摸索,现将汉化方法公布如下,请放心,绝对可以成功!(一)Xtreme库文件汉化:
1、将Include/L.cn下的XTResource.rc复制到Include目录下,替换原先的文件,由于该中文资源文件的汉化不是十分彻底,你可以自己把该文件中其余的英文翻译为中文;
2、在VC中打开XTToolkit_Dll\XTToolkit_Dll.dsw工程文件,现在你可以打开ResourceView观察汉化后的对话框和字符串;
3、如果现在你编译的话,会发现资源文件编译错误,这是因为你还没有设定合适的字符编码,不过有些朋友运气好的话,可能仍然可以通过编译,但在运行会发生乱码现象,因此,设定资源的字符编码是必须的。通过菜单【View->Resource Includes...】,修改“Compile-time directives:”框中的内容:
LANGUAGE 4, 2
#pragma code_page(936)
4、OK!可以编译了,不过别忘了打开Build工具栏,选择不同的编译模式哦!注 :在汉化的同时,你可以修改src/XTGlobal.cpp文件,这个文件里面有一个Bug,不过它只对Debug模式编译的文件敏感,修改如下:// if ( ( lfHorz.lfCharSet & SYMBOL_CHARSET ) == 0 ) // line 274
if ( ( lfHorz.lfCharSet & DEFAULT_CHARSET ) == 0 )
(二)向导的汉化
1、打开工程文件XTAppWizard_v6\XTAppWizard.dsw;(我用的VC6)
2、修改文件XTAppWizardAw.cpp,如下:// This is called immediately after the custom AppWizard is loaded. Initialize
// the state of the custom AppWizard here.
void CXTAppWizardAppWiz::InitCustomAppWiz()
{
// Create a new dialog chooser; CDialogChooser's constructor initializes
// its internal array with pointers to the steps.
m_pChooser = new CDialogChooser;// At first, we don't know the total number of steps, since there are two
// possible "tracks" (MDI/SDI app and dialog-based app).
SetNumberOfSteps(-1);// Inform AppWizard of the languages we support
//SetSupportedLanguages(_T("German [Standard] (APPWZDEU.DLL);0x40704b0\nEnglish [United States] (APPWZENU.DLL);0x40904b0\nSpanish [International Sort] (APPWZESP.DLL);0xc0a04b0\nFrench [Standard] (APPWZFRA.DLL);0x40c04b0\nItalian [Standard] (APPWZITA.DLL);0x41004b0"));
SetSupportedLanguages(_T("中文 [中国] (APPWZCHS.DLL);0x80404b0\nEnglish [United States] (APPWZENU.DLL);0x40904b0\nSpanish [International Sort] (APPWZESP.DLL);0xc0a04b0\nFrench [Standard] (APPWZFRA.DLL);0x40c04b0\nItalian [Standard] (APPWZITA.DLL);0x41004b0"));
//-----------------------------------------------------------------------
// Initial settings for the standard control bar class.
//-----------------------------------------------------------------------
..........
........
2、OK,你可以编译了,生成的XTAppWizard_vc6.awx文件将自动复制为(MSDEVDIR)\Template\XTAppWizard.awx;
3、运行向导时请选择中文资源。
注 :你可以对Wizard的对话框资源进行汉化,不过这仅仅是向导的界面汉化,对于向导的运行结果没有半点影响。Xtreme ToolKit 字体说明
根据 Xtreme ToolKit 帮助的说明,如果需要设置 Xtreme ToolKit 的字体,可以在 app 类的 InitInstance 函数中做如下的代码
// get the log font currently used by the toolkit
XT_LOGFONT lf;
xtAfxData.font.GetLogFont( &lf );// change the font to Verdana
_tcscpy( lf.lfFaceName, _T( "Verdana" ) );// set the font used by the toolkit.
CFont font;
font.CreateFontIndirect( &lf );
xtAfxData.SetGlobalFont( &font ); // 这句会 ASSERT 失败但在具体的使用中,因为通常要将字体改为宋体 9 号,这样做会在 Debug 模式下 ASSERT 失败(VC7,VC6 没试),原因是 CFont 在 Attach 时未 Detach,所以应该上述代码前增加一句,如:
font.CreateFontIndirect( &lf );
xtAfxData.FreeSysFonts(); // 先 Free 掉以前的资源
xtAfxData.SetGlobalFont( &font );
这样就可以了,
但在随后的调用中,如果需要使用垂直字体时,如 CXTToolBar 还会有 ASSERT 失败,所以,最好是使用以下的代码:// get the log font currently used by the toolkit
XT_LOGFONT lf;
xtAfxData.font.GetLogFont( &lf );// change the font to Verdana
lf.lfHeight = 12;
lf.lfWidth = 0;
lf.lfCharSet = GB2312_CHARSET;// 正常字体
_tcscpy( lf.lfFaceName, _T( "宋体" ) );
CFont font;
font.CreateFontIndirect( &lf);// 垂直字体
CFont vfont;
_tcscpy( lf.lfFaceName, _T( "@宋体" ) );
vfont.CreateFontIndirect( &lf);// set the font used by the toolkit.
xtAfxData.FreeSysFonts();
xtAfxData.SetGlobalFont(&font, &vfont);这样做的结果是你的应用程序更象一个标准的中文软件。
XT 中 DocBar 的 Caption 的字体
因为 CXTDockWindow 的基类 CXTControlBar 使用了 8pt 固定字体,所以比通常的字体小
void CXTControlBar::UpdateControlBarFonts()
{
...
int iHeight = -::MulDiv(8, ::GetDeviceCaps(dc.m_hDC, LOGPIXELSY), 72); // 在此处固定
....
lf.lfHeight = iHeight;
m_font.CreateFontIndirect(&lf);
.......
}
导致 DocBar 在停靠时的 Caption 比较难看,针对以上问题
一 可以在运行时,在 ControlBar 的派生类中重新为 m_font 等赋于指定大小的字体,这种方法我以前尝试没有成功,虽然理论上好象没有问题,我是在 OnCreate 函数中做这件事的。二 修改 CXTControlBar::UpdateControlBarFonts() ,将上边的的实现修改成
void CXTControlBar::UpdateControlBarFonts()
{
...
int iHeight = -::MulDiv(9, ::GetDeviceCaps(dc.m_hDC, LOGPIXELSY), 72); // 在此处固定,由 8 号字增为 9 号字
....
lf.lfHeight = iHeight;
m_font.CreateFontIndirect(&lf);
.......
}
然后重新编译 DLL 即可,这样做成功了。
尽管对于中文的系统来说,第二种做法也算基本可行,但我想知道第一种方法为什么不行,有尝试过的朋友请跟贴讨论。