⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subject_20831.htm

📁 一些关于vc的问答
💻 HTM
字号:
<p>
序号:20831 发表者:小许 发表日期:2002-11-11 12:57:45
<br>主题:怎样实现中英文界面的动态变换,就像QQ换面板一样。
<br>内容:各位大虾:<BR>&nbsp;&nbsp;本人有一个困扰很久的问题,就是动态切换中英文界面。<BR>我把我的中英文资源文件分别封装在两个DLL文件中<BR>然后在BOOL CMyApp::InitInstance()里加入下列代码<BR>//载入资源动态链接库<BR>&nbsp;&nbsp;&nbsp;&nbsp;if (isChinese)&nbsp;&nbsp; m_hLangDLL=AfxLoadLibrary(_T("ChineseDLL.dll"));<BR>&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;&nbsp;m_hLangDLL=AfxLoadLibrary(_T("EnglishDLL.dll"));<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;if (!m_hLangDLL)<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AfxMessageBox(_T("Unable to load resource DLL!"));<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return FALSE;<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;//将资源动态链接库设置为资源来源<BR>&nbsp;&nbsp;&nbsp;&nbsp;AfxSetResourceHandle(m_hLangDLL);<BR><BR>但问题是以上代码并不能实现程序在运行中动态切换界面,你只能在程序启动时就决定选用哪一种界面,而我想在程序中动态切换就用QQ换面板一样先最小化再最大化就切换了界面。<BR>不知道哪位大虾能给小生一个指示,在此先谢过了!<BR>
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
回复者:雷神 回复日期:2002-11-11 13:15:29
<br>内容:你可以试试用string Table定制多种语言。然后在程序中控制LoadString()实现。
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:小许 回复日期:2002-11-11 13:48:01
<br>内容:但是我觉得在程序中控制LoadString()太麻烦了,程序中的字符资源很多,我是基于FormView的程序,上面有很多控件也要实现中英文,还有很多的LoadString,这样做太麻烦了,有没有更好的解决方法??
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:徐景周 回复日期:2002-11-11 13:49:06
<br>内容:http://www.copathway.com/cndevforum/subject_view.asp?subject_id=17385&forum_id=
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:雷神 回复日期:2002-11-11 14:03:18
<br>内容:可以写一个函数,用循环遍历所有的控件。范围可以设定。<BR>例如:<BR>CString str;<BR>for(int i=ID_NEWFILE_CN;i&lt;=ID_EXIT_CN;i++)<BR>{<BR>......<BR>str.LoadString(i);<BR>......<BR>}
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:小许 回复日期:2002-11-11 20:19:44
<br>内容: 请大家仔细看一下我的代码,以上你们所说的我都嫌麻烦了。<BR><BR>然后在BOOL CMyApp::InitInstance()里加入下列代码<BR>//载入资源动态链接库<BR>&nbsp;&nbsp;&nbsp;&nbsp;if (isChinese)&nbsp;&nbsp; m_hLangDLL=AfxLoadLibrary(_T("ChineseDLL.dll"));<BR>&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;&nbsp;m_hLangDLL=AfxLoadLibrary(_T("EnglishDLL.dll"));<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;if (!m_hLangDLL)<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AfxMessageBox(_T("Unable to load resource DLL!"));<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return FALSE;<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;//将资源动态链接库设置为资源来源<BR>&nbsp;&nbsp;&nbsp;&nbsp;AfxSetResourceHandle(m_hLangDLL);<BR><BR>像以上这样很简单,只是不能实现动态变换请各位再想想办法。。
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:小许 回复日期:2002-11-13 08:31:28
<br>内容:大家有没有什么办法???
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:Supernatural 回复日期:2002-11-13 11:10:23
<br>内容:可以实现动态切换的啊!<BR>你可以增加一个语言选择菜单,一个为中文,一个为英文。<BR>在响应中调用&nbsp;&nbsp;SetLanguage(int Value=0);&nbsp;&nbsp;//自定义函数,用来加载资源库<BR><BR>void ***::SetLanguage(int Value);<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;// Example: 0 English&nbsp;&nbsp;1 Chinese<BR>&nbsp;&nbsp;&nbsp;&nbsp;//此处还可以用一个变量来保存语设置,如果相同的话可以直接退出<BR> <BR>&nbsp;&nbsp;&nbsp;&nbsp;HINSTANCE hInst=NULL;<BR>&nbsp;&nbsp;&nbsp;&nbsp;switch(Value)<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp; case 0:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hInst=AfxLoadLibrary(_T("EnglishDLL.dll"));<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<BR>&nbsp;&nbsp;&nbsp;&nbsp; case 1:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hInst=AfxLoadLibrary(_T("ChineseDLL.dll"));<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;if (NULL != hInst)<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// modify resource handle<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AfxSetResourceHandle(hInst);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//修改主窗口资源; 此处只修改了菜单<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HMENU hmenu = ::LoadMenu(hInst,MAKEINTRESOURCE(IDR_MAINFRAME));<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;::SetMenu(m_pMainWnd-&gt;GetSafeHwnd(),hmenu);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_pMainWnd-&gt;DrawMenuBar();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(NULL!=m_hLangDLL)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AfxFreeLibary(m_hLangDLL);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_hLangDLL = hInst;<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//设置标志为当前语言,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//用以下次加载时做比较<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>}
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:小许 回复日期:2002-11-13 13:46:43
<br>内容:太好了,我的菜单确实能动态变化了。非常感谢楼上的Supernatural,真的谢谢你!<BR>但是我这是一个基于CFormView的程序,我有一个主界面IDD_TESTMOTOR_FORM,如下:<BR>class CTestMotorView : public CFormView<BR>{<BR>protected: // create from serialization only<BR>&nbsp;&nbsp;&nbsp;&nbsp;CTestMotorView();<BR>&nbsp;&nbsp;&nbsp;&nbsp;DECLARE_DYNCREATE(CTestMotorView)<BR><BR>public:<BR>&nbsp;&nbsp;&nbsp;&nbsp;//{{AFX_DATA(CTestMotorView)<BR>&nbsp;&nbsp;&nbsp;&nbsp;enum { IDD = IDD_TESTMOTOR_FORM };<BR>&nbsp;&nbsp;...<BR>}<BR>我在这个对话框中有很多控件如静态框,很多按钮啊什么的,我怎样也能实现这些控件标题的中英文动态转换呢???<BR>在线等待你的回答!!<BR><BR><BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:似水流年 回复日期:2002-11-16 17:43:49
<br>内容:没有人理我了???
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -