以下是引用片段: 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 ...{ 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 ...{ 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 ...{ strline = FileContainer.GetAt(i++); strline.TrimLeft(); if(strline.GetLength()<=0) continue; //跳過空行 if(strline.Left(2)=="http://") 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 ...{ strline = FileContainer.GetAt(i++); strline.TrimLeft(); if(strline.GetLength()<=0) continue; //跳過空行 if(strline.GetAt(0)=='[') return bRead;//假如到達下一個[],即找不到,返回默認值 if(strline.Left(2)=="http://") 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遍歷結(jié)束 } //沒有找到Section } //當前行遍歷結(jié)束 } return bRead; } |
以下是引用片段: BOOL CLanguageManager::setControlCaption(CWnd * pCtrl, UINT ctrlID) ...{ BOOL isOK=FALSE; for(int i=0;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(); } } |
|
新聞熱點
疑難解答