代码:
int nStructSize = ; //Win98 as default LPARAM lModuleParam = ; TV_INSERTSTRUCT tvItem; CString sPathNameSel; char lpszCurrentDir[];//1K ::GetModuleFileName(NULL, lpszCurrentDir, ); //Get current directory int n = CString(lpszCurrentDir).ReverseFind('\\'); CString sTemp = CString(lpszCurrentDir).Left(n); STRCPY(lpszCurrentDir, sTemp); CString str("", ); /*if (TRUE == bAMT700PrjModify) { bAMT700PrjModify = FALSE; int nAnswer = MxMessageBox(m_hWnd, IDS_SAVEPROJECTORNOT, IDS_CAPTION_NEWPROJECT, MB_YESNO); if (IDYES == nAnswer) { OnBnClickedBtnAmt700PrjSave(); } } */ CFileDialog mFileDlg( TRUE, NULL, NULL, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, "IRIS Files (*.ini)|*.ini||", this); //NT does not support mFileDlg.m_ofn.lpstrFile = (LPSTR)(LPCTSTR)str;//.GetBuffer(MERGE_MAX_COUNT_OF_FILE_CAN_SELECT); mFileDlg.m_ofn.lpstrTitle = RESID2LPSTR(IDS_BROWSEFORPROJECT); mFileDlg.m_ofn.lpstrInitialDir = lpszCurrentDir; DWORD dwVersion = GetVersion(); if (dwVersion < 0x80000000) //Windows NT/win2000 { nStructSize = ; } else //Windows95/98 { nStructSize = ; } mFileDlg.m_ofn.lStructSize = nStructSize; str.ReleaseBuffer(); if (mFileDlg.DoModal() == IDOK) { POSITION pos = mFileDlg.GetStartPosition(); while (NULL != pos) { m_sPrjPathName = mFileDlg.GetNextPathName(pos); sPathNameSel = mFileDlg.GetFileName(); } CFileFind finder; DWORD dwFindRet; dwFindRet = m_sPrjPathName.Find(".ini"); if (0xffffffff == dwFindRet) { m_sPrjPathName += ".ini"; } dwFindRet = sPathNameSel.Find(".ini"); if (0xffffffff == dwFindRet) { sPathNameSel += ".ini"; } if (!finder.FindFile(m_sPrjPathName)) { MxMessageBox(m_hWnd, IDS_PROJECTNOTEXITS, IDS_CAPTION_OPENPROJECT, MB_ICONERROR); m_sPrjPathName.Empty(); return; } sPathNameSel = sPathNameSel.Left(sPathNameSel.GetLength() - strlen(".ini")); g_prjAMT700.Release(); /*m_treePrj.DeleteAllItems(); m_dlgModule.m_nModuleCount = 0; m_dlgModule.m_bMethod = 1; //add m_dlgAddr.ShowWindow(SW_HIDE); m_dlgModule.ShowWindow(SW_SHOW);*/ //CButton * pBtn = (CButton *)GetDlgItem(IDC_RAD_AMT700_MODULE); //pBtn->ShowWindow(SW_SHOW); //pBtn->SetCheck(1); //pBtn = (CButton *)GetDlgItem(IDC_RAD_AMT700_ADDR); //pBtn->ShowWindow(SW_SHOW); tvItem.hParent = TVI_ROOT; tvItem.hInsertAfter = TVI_ROOT; // tvItem.item.iImage = nImage; // tvItem.item.iSelectedImage = nImage; tvItem.item.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT | TVIF_PARAM; tvItem.item.pszText = CSTRING_TO_LPSTR sPathNameSel; tvItem.item.lParam = MAKELPARAM(g_prjAMT700.GetModuleCount(), MAKEWORD(/*PRJ*/, ));//Prj //m_hPrj = m_treePrj.InsertItem(&tvItem); //m_treePrj.SelectItem(m_hPrj); //if (AMT700_VERSION == iAMTVer) //{ // g_prjAMT700.LoadProject(m_sPrjPathName); // for (int i = 0; i < g_prjAMT700.GetModuleCount(); i++) // { // CModule700 * pTmpModule = g_prjAMT700.GetModuleAt(i); // lModuleParam = MAKELPARAM(i, MAKEWORD(2/*Module*/, 0)); // HTREEITEM hItem = AddModuleItem(m_hPrj, *pTmpModule, lModuleParam); // m_dlgModule.m_nModuleCount++; // for (int j = 0; j < pTmpModule->GetAddrCount(); j++) // { // CAddr700 pTmpAddr; // pTmpModule->GetAddrAtEx(j, &pTmpAddr); // AddAddrItem(hItem, pTmpAddr, MAKELPARAM(j, MAKEWORD(3, 0))); // } // } //} }