MFC程序中树视图中英文转换

站在高处看风景 2014-03-09 07:40:31
我想写一个mfc程序,其中一个功能是中英文界面的转换,但转换树视图时,老是出问题
ASSERT FXCMN_INLINE BOOL CTreeCtrl::SetItemText(HTREEITEM hItem, LPCTSTR lpszItem)
{ASSERT (::IsWindow(m_hWnd)); return SetItem(hItem, TVIF_TEXT, lpszItem, 0, 0, 0, 0, NULL); }

附上部分源码
void CMyTreeView::changelanguage()
{
HTREEITEM hRoot; // 树的根节点的句柄
HTREEITEM hCataItem; // 可表示任一分类节点的句柄
HTREEITEM hCWItem; // 可表示任一节点的句柄
CcccApp*pView=(CcccApp*)AfxGetApp();
if(pView->language==1)
{
CTreeCtrl&treeCtrl=GetTreeCtrl();
//m_ImageList.Create(IDB_HIST_NORMAL,16,1,RGB(255,0,255));
//treeCtrl.SetImageList(&m_ImageList,LVSIL_NORMAL);
treeCtrl.SetItemText(hRoot,_T("三维地质建模"));
treeCtrl.SetItemText(hCataItem,_T("层位数据"));
treeCtrl.SetItemText(hCWItem,_T("第一层"));
treeCtrl.SetItemText(hCWItem,_T("第二层"));
treeCtrl.SetItemText(hCWItem,_T("第三层"));
treeCtrl.SetItemText(hCataItem,_T("断层数据"));
treeCtrl.SetItemText(hCWItem,_T("断层一"));
treeCtrl.SetItemText(hCWItem,_T("断层二"));
treeCtrl.SetItemText(hCWItem,_T("断层三"));
treeCtrl.SetItemText(hCataItem,_T("SGY数据"));
treeCtrl.SetItemText(hCWItem,_T("切片显示"));
treeCtrl.SetItemText(hCWItem,_T("体数据显示"));

TODO: 在此添加专用代码和/或调用基类
m_ImageList img;
m_ImageList.Create(16,16,ILC_COLOR24|ILC_MASK,1,1);
m_ImageList.Add(LoadIcon(AfxGetResourceHandle(),MAKEINTRESOURCE(IDI_ICON1)));
m_ImageList.Add(ExtractIcon(AfxGetApp()-> m_hInstance,"shell32.dll ",6));
m_ImageList.Add(ExtractIcon(AfxGetApp()-> m_hInstance,"shell32.dll ",24));
m_ImageList.Add(ExtractIcon(AfxGetApp()-> m_hInstance,"shell32.dll ",11));
treeCtrl.SetImageList(&m_ImageList,TVSIL_NORMAL);

}
if(pView->language==0)
{

CTreeCtrl&treeCtrl=GetTreeCtrl();
//m_ImageList.Create(IDB_HIST_NORMAL,16,1,RGB(255,0,255));
//treeCtrl.SetImageList(&m_ImageList,LVSIL_NORMAL);
treeCtrl.SetItemText(hRoot,_T("three-dimensional geological modeling"));//插入根节点
treeCtrl.SetItemText(hCataItem,_T("Horizon Data"));//添加第一个子节点
treeCtrl.SetItemText(hCWItem,_T("First"));
treeCtrl.SetItemText(hCWItem,_T("Second"));
treeCtrl.SetItemText(hCWItem,_T("Third"));
treeCtrl.SetItemText(hCataItem,_T("Fault Data"));
treeCtrl.SetItemText(hCWItem,_T("Fault one"));
treeCtrl.SetItemText(hCWItem,_T("Fault two"));
treeCtrl.SetItemText(hCWItem,_T("Fault three"));
treeCtrl.SetItemText(hCataItem,_T("SEGY Data"));
treeCtrl.SetItemText(hCWItem,_T("Slice"));
treeCtrl.SetItemText(hCWItem,_T("Full"));

TODO: 在此添加专用代码和/或调用基类
//m_ImageList img;
m_ImageList.Create(16,16,ILC_COLOR24|ILC_MASK,1,1);
// m_ImageList.Add(LoadIcon(AfxGetResourceHandle(),MAKEINTRESOURCE(IDI_ICON1)));
m_ImageList.Add(ExtractIcon(AfxGetApp()-> m_hInstance,"shell32.dll ",6));
m_ImageList.Add(ExtractIcon(AfxGetApp()-> m_hInstance,"shell32.dll ",24));
m_ImageList.Add(ExtractIcon(AfxGetApp()-> m_hInstance,"shell32.dll ",11));
treeCtrl.SetImageList(&m_ImageList,TVSIL_NORMAL);

}
}

void CMainFrame::OnChinese()
{
// TODO: 在此添加命令处理程序代码
//CMenu pMenu;
CMyTreeView*pTView=(CMyTreeView*)AfxGetApp();
pMenu.Detach();
pMenu.LoadMenu(IDR_MAINFRAME);
SetMenu(NULL);
SetMenu(&pMenu);

CcccApp*pApp = (CcccApp*)AfxGetApp();
pApp->m_pMainWnd->SetWindowText("长江大学油气信息处理与识别研究所"); //标题
CcccApp*pView=(CcccApp*)AfxGetApp();
pView->language=0;
pTView->changelanguage();
// UpdateData(TRUE);


}

void CMainFrame::OnEnglish()
{
// TODO: 在此添加命令处理程序代码
//CMenu pMen;
CMyTreeView*pTView=(CMyTreeView*)AfxGetApp();
pMenu.Detach();
pMenu.LoadMenu(IDR_MENU1);
SetMenu(NULL);
SetMenu(&pMenu);
CcccApp*pApp = (CcccApp*)AfxGetApp();
pApp->m_pMainWnd->SetWindowText("Yangtze University"); //标题
CcccApp*pView=(CcccApp*)AfxGetApp();
pView->language=1;
pTView->changelanguage();
// UpdateData(TRUE);


}
...全文
214 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

3,881

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 其它技术问题
社区管理员
  • 其它技术问题社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧