扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
strCaption = fileManager.GetString(section,"IDC_Stc_ListStudent",""); SetDlgItemText(IDC_Stc_ListStudent,strCaption); strCaption = fileManager.GetString(section,"IDC_Stc_AllContent",""); SetDlgItemText(IDC_Stc_AllContent,strCaption); |
BOOL CLanguageManager::loadFromFile() ...{ BOOL bRead=FALSE; int i; ItemContext temp; CStringArray itemBuf,valueBuf; bRead = fileManager.GetSectionValues("Main Window",itemBuf,valueBuf); if(bRead) ...{ for(i=0;i<itemBuf.GetSize();i++) ...{ temp.uCtrlID = atoi(itemBuf.GetAt(i)); temp.strContext = valueBuf.GetAt(i); m_vtContexts.push_back(temp); } } itemBuf.RemoveAll(); valueBuf.RemoveAll(); bRead = fileManager.GetSectionValues("Login Dialog",itemBuf,valueBuf); if(bRead) ...{ for(i=0;i<itemBuf.GetSize();i++) ...{ temp.uCtrlID = atoi(itemBuf.GetAt(i)); temp.strContext = valueBuf.GetAt(i); m_vtContexts.push_back(temp); } } return bRead; } |
BOOL CIniFile::GetSectionValues(CString Section, CStringArray &strItemBuf, CStringArray &strValueBuf) ...{ BOOL bRead = FALSE; ReadIniFile();//打开文件 if(bFileExist == FALSE || FileContainer.GetSize() < 0) return bRead;//文件打开出错或文件为空,返回默认值 int i = 0; int iFileLines = FileContainer.GetSize(); CString strline,str; while(i<iFileLines) ...{ strline = FileContainer.GetAt(i++); strline.TrimLeft(); if(strline.GetLength()<=0) continue; //跳过空行 if(strline.Left(2)=="//") continue; //跳过注释行 if(strline.GetAt(0)=='[')//查找Section,第一个必须为[ ...{ str=strline.Left(strline.Find("]"));//去掉]右边 str=str.Right(str.GetLength()-str.Find("[")-1);//去掉[左边 str.TrimLeft(); str.TrimRight(); if(Section == str)//找到Section ...{ while(i<iFileLines) ...{ strline = FileContainer.GetAt(i++); strline.TrimLeft(); if(strline.GetLength()<=0) continue; //跳过空行 if(strline.GetAt(0)=='[') return bRead;//如果到达下一个[],即找不到,返回默认值 if(strline.Left(2)=="//") continue; //跳过注释行 str = strline.Left(strline.Find("="));//去掉=右边 str.TrimLeft(); str.TrimRight(); //保存等号左边项 strItemBuf.Add(str); str=strline.Right(strline.GetLength()-strline.Find("=")-1);//去掉=左边 str.TrimLeft(); str.TrimRight(); //保存等号右边项 strValueBuf.Add(str); bRead = TRUE; } //当前Section遍历结束 } //没有找到Section } //当前行遍历结束 } return bRead; } |
BOOL CLanguageManager::setControlCaption(CWnd * pCtrl, UINT ctrlID) ...{ BOOL isOK=FALSE; for(int i=0;i<m_vtContexts.size();i++) ...{ isOK = (m_vtContexts[i].uCtrlID==ctrlID); if(isOK) ...{ pCtrl->SetWindowText(m_vtContexts[i].strContext); break; } } return isOK; } |
void CLanguageManager::setCaptionForWindow(CWnd * pWnd) ...{ //枚举对话框中所有组件 CWnd *pCtrl = pWnd->GetWindow(GW_CHILD); while(pCtrl!=NULL) ...{ UINT ctrlID = pCtrl->GetDlgCtrlID(); setControlCaption(pCtrl,ctrlID); pCtrl = pCtrl->GetNextWindow(); } } |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者