void CTechsView::OnSelchanged(NMHDR* pNMHDR, LRESULT* pResult) { NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR; // TODO: Add your control notification handler code here CTreeCtrl &treectrl = GetTreeCtrl(); HTREEITEM hItem = treectrl.GetSelectedItem(); CString strText = treectrl.GetItemText(hItem); if( NULL != hItem ) { UINT nTech = treectrl.GetItemData(hItem); if( (nTech >= STT_MIN && nTech <= STT_MAX) || nTech >= STT_USER_MIN ) { AfxGetProfile().ShowGraphViewTech( nTech ); CGraphView * pGraphView = AfxGetGraphView(); CView * pActiveView = AfxGetStaticDoc()->GetActiveView(); if( pGraphView ) pGraphView->ResetClientRect( ); if( pGraphView && pGraphView->GetSafeHwnd() == pActiveView->GetSafeHwnd() ) pGraphView->Invalidate(); else AfxSwitchToStaticView( RUNTIME_CLASS(CGraphView) ); SetFocus( ); } } *pResult = 0; }
void CStrategyView::ExecuteStrategy( CStrategy * pStrategy, DWORD dwData ) { if( NULL != pStrategy ) { if( SV_ITEM_PROPERTY == dwData ) ::PostMessage( AfxGetMainFrame()->GetSafeHwnd(), WM_COMMAND, ID_STRATEGY_PROPERTY, 0 ); else if( SV_ITEM_STOCKS == dwData ) AfxShowSlist( CStockContainer::typeStrategy, NULL ); else if( SV_ITEM_RULE == dwData ) ::PostMessage( AfxGetMainFrame()->GetSafeHwnd(), WM_COMMAND, ID_STRATEGY_SETRULE, 0 ); else if( SV_ITEM_RATE == dwData ) ::PostMessage( AfxGetMainFrame()->GetSafeHwnd(), WM_COMMAND, ID_STRATEGY_SETRATE, 0 ); else if( SV_ITEM_SIMU == dwData ) AfxSwitchToStaticView( RUNTIME_CLASS(CSimuView) ); else if( SV_ITEM_REPORT == dwData ) ::PostMessage( AfxGetMainFrame()->GetSafeHwnd(), WM_COMMAND, ID_STRATEGY_REPORT, 0 ); else if( SV_ITEM_REALOP == dwData ) ::PostMessage( AfxGetMainFrame()->GetSafeHwnd(), WM_COMMAND, ID_STRATEGY_REALOP, 0 ); else AfxSwitchToStaticView( RUNTIME_CLASS(CSimuView) ); } }
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; }
BOOL CGraphView::PreTranslateMessage(MSG* pMsg) { if( WM_KEYDOWN == pMsg->message ) { switch( pMsg->wParam ) { case VK_F5: { AfxSwitchToStaticView( RUNTIME_CLASS(CRealTimeView) ); CRealTimeView * pView = AfxGetRealTimeView( ); if( pView ) pView->ChangeDrawMode( CRealTime::modePriceLine ); } return TRUE; } } return CView::PreTranslateMessage(pMsg); }
BOOL CStkUIApp::InitInstance() { // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need. AfxSocketInit( ); AfxOleInit(); // 程序只能启动一个实例 m_pMutex = CreateMutex(NULL, FALSE, _T("TsKing")); if (m_pMutex != NULL) { if (GetLastError() == ERROR_ALREADY_EXISTS) { CloseHandle(m_pMutex); m_pMutex = NULL; return FALSE; } } GetVersionNumber(); AfxGetProfile().LoadProfile( ); ::SetCurrentDirectory( AfxGetProfile().GetWorkDirectory() ); AfxGetSView().Load( AfxGetProfile().GetSViewFile() ); // Change the registry key under which our settings are stored. // TODO: You should modify this string to be something appropriate // such as the name of your company or organization. // SetRegistryKey( szRegKeyCompany ); AfxRegSetValue( szRegKeyCompany, szRegKeyApp, "Install", "Path", AfxGetProfile().GetWorkDirectory() ); AfxRegSetValue( szRegKeyCompany, szRegKeyApp, "Install", "Version", AfxGetProfile().GetVersion() ); // change profile ( INI file ) BOOL bEnable = AfxEnableMemoryTracking(FALSE); if( m_pszProfileName ) free((void*)m_pszProfileName); m_pszProfileName = _tcsdup(AfxGetProfile().GetWorkDirectory()+m_pszExeName+".ini"); AfxEnableMemoryTracking(bEnable); LoadStdProfileSettings(64); // Load standard INI file options (including MRU) // Register the application's document templates. Document templates // serve as the connection between documents, frame windows and views. // Enable DDE Execute open EnableShellOpen(); AfxUnregisterShellFileTypes(); // AfxRegisterShellFileTypes(FALSE); // Empty Temp Directory { CNetDatabase netdb; if (netdb.SetRootPath(AfxGetProfile().GetSelfDBPath(), IStStore::dbtypeSelfDB)) netdb.EmptyTempDirectory(); } AfxSetDB(&AfxGetNetDB()); //*/ // Load Data char szErr[1024]; if (!AfxInitializeDB(szErr, sizeof(szErr))) { AfxMessageBox(szErr, MB_OK | MB_ICONINFORMATION); return FALSE; } // 初始化 AfxGetStockContainer().Load(&AfxGetDB(), NULL, NULL); // 读取证券信息,代码表、财务、除权等 AfxGetDomainContainer().Load(AfxGetProfile().GetDomainFile()); // 读取板块 AfxGetGroupContainer().Load(AfxGetProfile().GetGroupFile()); // 读取自选板块 // 分析标准外壳命令、DDE、打开文件操作的命令行 CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); #ifdef _TSK_MAINFRAME // 注册应用程序的文档模板。文档模板 // 将用作文档、框架窗口和视图之间的连接 CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CStaticDoc), RUNTIME_CLASS(CMainFrame), // 主 SDI 框架窗口 RUNTIME_CLASS(CSListView)); if (!pDocTemplate) return FALSE; AddDocTemplate(pDocTemplate); // 调度在命令行中指定的命令。如果 // 用 /RegServer、/Register、/Unregserver 或 /Unregister 启动应用程序,则返回 FALSE。 if (!ProcessShellCommand(cmdInfo)) return FALSE; #else // Create MainFrame and Static Doc and child frames and static views CStaticDoc* pStaticDoc = CStaticDoc::OpenDocumentFile(NULL); if (pStaticDoc == NULL) { AfxMessageBox(IDS_STATICDOC_FAILED, MB_OK | MB_ICONINFORMATION); return FALSE; } pStaticDoc->m_bAutoDelete = FALSE; CString strAppTitle; strAppTitle.LoadString(AFX_IDS_APP_TITLE); pStaticDoc->SetTitle(strAppTitle); SetStaticDoc(pStaticDoc); // Create MainFrame CMainFrame* pMainFrame = CMainFrame::CreateNewFrame(); if (pMainFrame == NULL) { AfxMessageBox(IDS_STATICDOC_FAILED, MB_OK | MB_ICONINFORMATION); delete pStaticDoc; SetStaticDoc(NULL); return FALSE; } SetMainWnd(pMainFrame); #endif // 股票行情接收 AfxGetStkReceiver().CreateReceiver(m_pMainWnd); AfxGetStkReceiver().NetEngineSetAutoReport(FALSE); /* Show Startup Window CStartupDlg startup; CBitmap bmp; bmp.LoadBitmap(IDB_DLGLEFTLOGO); startup.SetBitmap((HBITMAP)bmp.GetSafeHandle()); startup.SetLoadProgramFunc(LoadProgram); if (IDOK != startup.DoModal()) { pMainFrame->SendMessage(WM_CLOSE); return FALSE; } //*/ /* Show Splash Window CSplashDlg splash; CBitmap bmp; bmp.LoadBitmap(IDB_SPLASH); splash.SetBitmap(HBITMAP(bmp.GetSafeHandle())); splash.Create(NULL, 0, AfxGetSView().GetU(), AfxGetSView().GetS(), AfxGetVersionString(), FALSE, 0, STKLIB_MAX_PROGRESS); splash.ShowWindow(SW_SHOW); splash.UpdateWindow(); LoadProgram(splash.GetSafeHwnd(), 0, STKLIB_MAX_PROGRESS); splash.DestroyWindow(); //*/ // ////////////////////////////////////////////////////////////// // Open Simulation Strategy if (GetFirstStrategyPosition() == NULL) { if (OpenLastOpenedStrategy() == 0) OpenDefaultStrategy(); } //if (!AfxGetStaticDoc()->GetViewIfExist(RUNTIME_CLASS(CSListView))) // AfxGetStaticDoc()->ShowStaticView(RUNTIME_CLASS(CSListView), TRUE); //AfxSwitchToStaticView(RUNTIME_CLASS(CSListView)); AfxGetProfile().SetCurrentStock(STKLIB_CODE_SZZS, FALSE); ((CMainFrame*)m_pMainWnd)->m_SearchBox.InitStocks( TRUE, TRUE, TRUE ); ((CMainFrame*)m_pMainWnd)->m_SearchBox.SetCurrentWindowText(); //*////////////////////////////////////////////////////////////// // Dispatch commands specified on the command line if( CCommandLineInfo::AppUnregister == cmdInfo.m_nShellCommand ) { AfxUnregisterShellFileTypes(); if (!cmdInfo.m_bRunEmbedded) AfxMessageBox(AFX_IDP_UNREG_DONE, MB_OK | MB_ICONINFORMATION); if (m_pCmdInfo == NULL) { m_pCmdInfo = new CCommandLineInfo; m_pCmdInfo->m_nShellCommand = CCommandLineInfo::AppUnregister; } return FALSE; } // Dispatch commands specified on the command line if (cmdInfo.m_nShellCommand == CCommandLineInfo::FileOpen) { OpenStrategyFile(cmdInfo.m_strFileName); AfxSwitchToStaticView(RUNTIME_CLASS(CSimuView)); } // 启动通视接收系统,不显示选择接收系统对话框 //AfxGetStkReceiver().EngineBeginWorking(FALSE); // The one and only window has been initialized, so show and update it. // Load Last WindowPlacement WINDOWPLACEMENT wp; if (AfxGetProfile().GetWindowPlacement(&wp)) m_pMainWnd->SetWindowPlacement(&wp); else m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED); // Enable drag/drop open //m_pMainWnd->DragAcceptFiles(); // Check New Version m_pMainWnd->SetTimer(TIMER_AUTOUPDATE, 5000, NULL); return TRUE; }
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; }