BOOL CGDSApp::OnOpenRecentFile(UINT nID) {//@CODE_3639 CRecentFileList *appRFL; LPTSTR tExt; CDLLInterface *ri; appRFL = GetRecentFileList(); ASSERT(appRFL != NULL); ASSERT(nID >= ID_FILE_MRU_FILE1); ASSERT(nID < ID_FILE_MRU_FILE1 + (UINT)appRFL->GetSize()); int nIndex = nID - ID_FILE_MRU_FILE1; ASSERT((*appRFL)[nIndex].GetLength() != 0); TRACE2("MRU: open file (%d) '%s'.\n", (nIndex) + 1, (LPCTSTR)(*appRFL)[nIndex]); // figure out type of resource wanted, by extension // get last . to find start of extension tExt = _tcsrchr((*appRFL)[nIndex], '.'); // if not found, then no extension if ((tExt == NULL) || ((ri = FindExtensionMatch(tExt, TRUE)) == NULL)) { MessageBox(GetMainWnd()->m_hWnd,_T("Unable to match extension for MRU file type.\n"), _T("Extension Error!"), MB_OK); return FALSE; } // Load/Create new resource if (!ri->Load((LPTSTR)(LPCTSTR)(*appRFL)[nIndex])) appRFL->Remove(nIndex); return TRUE; }//@CODE_3639
void CWizardView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) { // TODO: Add your specialized code here and/or call the base class if( UPDATE_HINT_WIZARDVIEW != lHint ) { if( ::IsWindow( m_listRecent.GetSafeHwnd() ) ) m_listRecent.Invalidate( ); return; } if( IsWindowVisible() ) SetFocus( ); m_listRecent.DeleteAllItems( ); // insert items CStkUIApp * pApp = AfxGetStkUIApp(); CRecentFileList * pRecent = NULL; if( pApp ) pRecent = pApp->GetRecentFileList( ); CString strOpened; strOpened.LoadString( IDS_STRATEGYOPENED ); CStringArray astrAdded; int count = 0; if( pRecent ) { for( int i=pRecent->GetSize()-1; i>=0; i-- ) { CString strPath = (*pRecent)[i]; if( strPath.IsEmpty() ) continue; if( 0 != access(strPath,0) ) { pRecent->Remove(i); continue; } TCHAR szFullPath[_MAX_PATH]; AfxFullPath( szFullPath, strPath ); strPath = szFullPath; CString strName = CStrategy::GetName( strPath ); BOOL bOpened = pApp->IsFileOpened( strPath ); int nItem = m_listRecent.InsertItem( count, strPath, bOpened ? 1 : 0 ); m_listRecent.SetItemText( nItem, 0, strName ); m_listRecent.SetItemText( nItem, 1, strPath ); if( bOpened ) m_listRecent.SetItemText( nItem, 3, strOpened ); astrAdded.Add( strPath ); CString strTime; CFileStatus status; if( CFile::GetStatus( strPath, status ) ) { strTime = status.m_mtime.Format( "%Y-%m-%d" ); m_listRecent.SetItemText( nItem, 2, strTime ); } count ++; } } CString strExt = AfxGetStrategyFileExt( ); if( !strExt.IsEmpty()) { CFileFind finder; BOOL bWorking = finder.FindFile( AfxGetFilePath( (LPCTSTR)AfxGetProfile().GetProjectPath(), LPCTSTR("*" + strExt) ) ); while( bWorking ) { bWorking = finder.FindNextFile(); CString strPath = finder.GetFilePath(); int i; for( i=0; i<astrAdded.GetSize(); i++ ) { if( 0 == strPath.CompareNoCase( astrAdded.ElementAt(i) ) ) break; } if( i < astrAdded.GetSize() ) continue; CString strName = CStrategy::GetName( strPath ); BOOL bOpened = pApp->IsFileOpened( strPath ); int nItem = m_listRecent.InsertItem( count, strPath, bOpened ? 1 : 0 ); m_listRecent.SetItemText( nItem, 0, strName ); m_listRecent.SetItemText( nItem, 1, strPath ); if( bOpened ) m_listRecent.SetItemText( nItem, 3, strOpened ); CString strTime; CFileStatus status; if( CFile::GetStatus( strPath, status ) ) { strTime = status.m_mtime.Format( "%Y-%m-%d" ); m_listRecent.SetItemText( nItem, 2, strTime ); } count ++; if( count >= 256 ) break; } finder.Close(); } m_listRecent.Invalidate( ); }