void CWizardView::OnBtnopenstrategy() { // TODO: Add your control notification handler code here CStkUIApp * pApp = AfxGetStkUIApp(); if( pApp ) pApp->OnFileOpen( ); }
LRESULT CStrategyView::OnRemoveStrategy(WPARAM wParam, LPARAM lParam) { CStkUIApp * pApp = AfxGetStkUIApp( ); if( ! pApp ) return -1; CTreeCtrl &treectrl = GetTreeCtrl(); HTREEITEM hWorksp = treectrl.GetRootItem( ); if( NULL == hWorksp ) return -1; if( treectrl.ItemHasChildren( hWorksp ) ) { HTREEITEM hStrategy = treectrl.GetChildItem( hWorksp ); while( NULL != hStrategy ) { CStrategy * pStrategy = (CStrategy *)treectrl.GetItemData( hStrategy ); HTREEITEM hStrategyNext = treectrl.GetNextSiblingItem( hStrategy ); if( !pApp->ExistStrategy( pStrategy ) ) { treectrl.DeleteItem( hStrategy ); if( m_pActiveStrategy == pStrategy ) m_pActiveStrategy = NULL; } hStrategy = hStrategyNext; } } ActivateStrategy( m_pActiveStrategy ); //default activate the first one return 0; }
LRESULT CStrategyView::OnAddStrategy(WPARAM wParam, LPARAM lParam) { CStkUIApp * pApp = AfxGetStkUIApp( ); if( ! pApp ) return -1; CTreeCtrl &treectrl = GetTreeCtrl(); CString strWorksp; VERIFY( strWorksp.LoadString( IDS_STRATEGYVIEW_STRATEGY ) ); HTREEITEM hWorksp = treectrl.GetRootItem( ); if( NULL == hWorksp ) VERIFY( hWorksp = treectrl.InsertItem(strWorksp,IMG_WORKSP,IMG_WORKSP_SEL) ); if( NULL == hWorksp ) return -1; POSITION pos = pApp->GetFirstStrategyPosition(); while( NULL != pos ) { CStrategy * pCurStrategy = pApp->GetNextStrategy( pos ); BOOL bExist = FALSE; if( NULL == GetItemByStrategy( pCurStrategy ) ) { HTREEITEM hStrategy = AddStrategy( pCurStrategy ); ActivateStrategy( pCurStrategy, hStrategy ); } } treectrl.Expand (hWorksp, TVE_EXPAND); return 0; }
void CWizardView::OnDblclkStrategylist(NMHDR* pNMHDR, LRESULT* pResult) { // TODO: Add your control notification handler code here for( int i=0; i<m_listRecent.GetItemCount( ); i++ ) { if( LVIS_SELECTED == m_listRecent.GetItemState(i,LVIS_SELECTED) ) { CString strPath = m_listRecent.GetItemText( i, 1 ); if( NULL != AfxGetStkUIApp()->OpenStrategyFile( strPath ) ) AfxSwitchToStaticView( RUNTIME_CLASS(CSimuView) ); } } *pResult = 0; }
void CDownloadDlg::OnCancel() { // TODO: Add extra cleanup here m_btnCancel.EnableWindow( FALSE ); AfxGetStkReceiver().RemoveRcvDataWnd( GetSafeHwnd() ); AfxReleaseDB(); char szErr[1024]; if( !AfxInitializeDB( szErr, sizeof(szErr) ) ) AfxMessageBox( szErr, MB_OK|MB_ICONINFORMATION ); CDialog::OnCancel( ); if( m_bDBModified ) { BOOL bRecalculate = FALSE; CSPTime tmLatest = 0; if( ( m_netdb.SetRootPath( AfxGetProfile().GetSelfDBPath(), IStStore::dbtypeSelfDB ) && m_netdb.GetTimeLocalRange( &tmLatest, NULL, NULL ) && tmLatest.GetTime() > m_tmLatestOld.GetTime() ) ) { bRecalculate = TRUE; } if( m_bAutoRun ) bRecalculate = FALSE; AfxGetStkUIApp()->OnDBChanged( FALSE /*bRecalculate*/ ); } if( !m_bAutoRun ) { CNetInfoDlg dlg; dlg.DoModal( ); if( AfxGetProfile().HasNewVersion() && IDYES == AfxMessageBox( IDS_DOWNLOAD_UPGRADENOW, MB_YESNO ) ) { CUpgradeDlg dlg; dlg.SetAutoRun( TRUE ); dlg.DoModal(); } } CXFDialog::PostNcDestroy(); }
void CInstallPacDlg::OnCompleted( ) { AfxReleaseDB(); char szErr[1024]; if( !AfxInitializeDB( szErr, sizeof(szErr) ) ) AfxMessageBox( szErr, MB_OK|MB_ICONINFORMATION ); if( m_bDBModified ) { BOOL bRecalculate = FALSE; CSPTime tmLatest = 0; if( m_bCodetableInstalled || ( m_netdb.SetRootPath( AfxGetProfile().GetSelfDBPath(), IStStore::dbtypeSelfDB ) && m_netdb.GetTimeLocalRange( &tmLatest, NULL, NULL ) && tmLatest.GetTime() > m_tmLatestOld.GetTime() ) ) { bRecalculate = TRUE; } AfxGetStkUIApp()->OnDBChanged( FALSE /*bRecalculate*/ ); m_bDBModified = FALSE; } }
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( ); }
BOOL CALLBACK LoadProgram( HWND hWnd, int nMinProgress, int nMaxProgress ) { int nMin = nMinProgress; int nMax = nMaxProgress; int nRange = nMaxProgress-nMinProgress; CStkUIApp * pApp = AfxGetStkUIApp(); if( NULL == pApp ) return FALSE; CStaticDoc * pStaticDoc = pApp->GetStaticDoc(); CMainFrame * pMainFrame = AfxGetMainFrame(); HINSTANCE hInstanceOld = AfxGetResourceHandle(); AfxSetResourceHandle( AfxGetInstanceHandle() ); SendMessage( hWnd, WM_USER_STARTUP_PROGRESS, nMin, 0 ); AfxGetStockContainer().Load( &AfxGetDB(), NULL, NULL ); AfxGetDomainContainer().Load( AfxGetProfile().GetDomainFile() ); AfxGetGroupContainer().Load( AfxGetProfile().GetGroupFile() ); SendMessage( hWnd, WM_USER_STARTUP_PROGRESS, nMin+nRange*4/30, 0 ); pMainFrame->m_SearchBox.InitStocks( TRUE, TRUE, TRUE ); //pMainFrame->m_DateBox.InitDates( ); SendMessage( hWnd, WM_USER_STARTUP_PROGRESS, nMin+nRange*8/30, 0 ); // Open Simulation Strategy if( NULL == pApp->GetFirstStrategyPosition() ) { if( 0 == pApp->OpenLastOpenedStrategy( ) ) pApp->OpenDefaultStrategy( ); } SendMessage( hWnd, WM_USER_STARTUP_PROGRESS, nMin+nRange*12/30, 0 ); // Show Views //if( !pStaticDoc->GetViewIfExist( RUNTIME_CLASS(CWizardView) ) ) // pStaticDoc->ShowStaticView( RUNTIME_CLASS(CWizardView), TRUE ); //SendMessage( hWnd, WM_USER_STARTUP_PROGRESS, nMin+nRange*14/30, 0 ); //if( !pStaticDoc->GetViewIfExist( RUNTIME_CLASS(CSimuView) ) ) // pStaticDoc->ShowStaticView( RUNTIME_CLASS(CSimuView), TRUE ); //SendMessage( hWnd, WM_USER_STARTUP_PROGRESS, nMin+nRange*16/30, 0 ); if( !pStaticDoc->GetViewIfExist( RUNTIME_CLASS(CSListView) ) ) pStaticDoc->ShowStaticView( RUNTIME_CLASS(CSListView), TRUE ); SendMessage( hWnd, WM_USER_STARTUP_PROGRESS, nMin+nRange*18/30, 0 ); //if( !pStaticDoc->GetViewIfExist( RUNTIME_CLASS(CRealTimeView) ) ) // pStaticDoc->ShowStaticView( RUNTIME_CLASS(CRealTimeView), TRUE ); //SendMessage( hWnd, WM_USER_STARTUP_PROGRESS, nMin+nRange*20/30, 0 ); //if( !pStaticDoc->GetViewIfExist( RUNTIME_CLASS(CMultiSortView) ) ) // pStaticDoc->ShowStaticView( RUNTIME_CLASS(CMultiSortView), TRUE ); //SendMessage( hWnd, WM_USER_STARTUP_PROGRESS, nMin+nRange*22/30, 0 ); //if( !pStaticDoc->GetViewIfExist( RUNTIME_CLASS(CGraphView) ) ) // pStaticDoc->ShowStaticView( RUNTIME_CLASS(CGraphView), TRUE ); //SendMessage( hWnd, WM_USER_STARTUP_PROGRESS, nMin+nRange*24/30, 0 ); //if( !pStaticDoc->GetViewIfExist( RUNTIME_CLASS(CBaseView) ) ) // pStaticDoc->ShowStaticView( RUNTIME_CLASS(CBaseView), TRUE ); //SendMessage( hWnd, WM_USER_STARTUP_PROGRESS, nMin+nRange*26/30, 0 ); //if( !pStaticDoc->GetViewIfExist( RUNTIME_CLASS(CInfoView) ) ) // pStaticDoc->ShowStaticView( RUNTIME_CLASS(CInfoView), TRUE ); //SendMessage( hWnd, WM_USER_STARTUP_PROGRESS, nMin+nRange*28/30, 0 ); //if( !pStaticDoc->GetViewIfExist( RUNTIME_CLASS(CSelectorView) ) ) // pStaticDoc->ShowStaticView( RUNTIME_CLASS(CSelectorView), TRUE ); AfxSwitchToStaticView( RUNTIME_CLASS(CSListView) ); AfxGetProfile().SetCurrentStock( STKLIB_CODE_SZZS, FALSE ); pMainFrame->m_SearchBox.SetCurrentWindowText( ); //pMainFrame->m_DateBox.SetWindowPos(NULL,0,0,135,200,SWP_NOMOVE|SWP_SHOWWINDOW|SWP_NOZORDER|SWP_NOREDRAW); AfxBeginThread( LoadKDataCacheMain, NULL, THREAD_PRIORITY_NORMAL); SendMessage( hWnd, WM_USER_STARTUP_PROGRESS, nMax, 0 ); AfxSetResourceHandle( hInstanceOld ); return TRUE; }