⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 realtimeview.cpp.svn-base

📁 股票软件源码
💻 SVN-BASE
📖 第 1 页 / 共 2 页
字号:

void CRealTimeView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CRealTimeView message handlers

int CRealTimeView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CView::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	CFont	font;
	if( !font.CreateStockObject( DEFAULT_GUI_FONT ) )
		font.CreateStockObject( ANSI_VAR_FONT );
	SetFont( &font );

	// tab
	if (!m_wndReportTab.Create(WS_VISIBLE|WS_CHILD,CRect(0,0,180,19),this,IDC_REALTIMEVIEW_REPORTTAB))
		return -1;
	
	CString	strName;
	strName.LoadString( IDS_REALTIMETAB_QUOTE );
	m_wndReportTab.Addtab( this, strName, -1);
	strName.LoadString( IDS_REALTIMETAB_PRICE );
	m_wndReportTab.Addtab( this, strName, -1);
	strName.LoadString( IDS_REALTIMETAB_MINUTE );
	m_wndReportTab.Addtab( this, strName, -1);
	strName.LoadString( IDS_REALTIMETAB_BUYSELLEX );
	m_wndReportTab.Addtab( this, strName, -1);
	strName.LoadString( IDS_REALTIMETAB_VALUE );
	m_wndReportTab.Addtab( this, strName, -1);
	strName.LoadString( IDS_REALTIMETAB_DISTRIBUTE );
	m_wndReportTab.Addtab( this, strName, -1);
	strName.LoadString( IDS_REALTIMETAB_BIGTRADE );
	m_wndReportTab.Addtab( this, strName, -1);

	m_wndReportTab.SetColorTabs(AfxGetProfile().GetColor(CColorClass::clrGraphBK));
	m_wndReportTab.SetSelectTabColor( AfxGetProfile().GetColor(CColorClass::clrGraphBK),
									AfxGetProfile().GetColor(CColorClass::clrTitle) );
	m_wndReportTab.SetAutoAjust(FALSE);
	m_wndReportTab.ShowButtonClose(FALSE);
	m_wndReportTab.SetALingTabs( CGuiTabWnd::ALN_BOTTOM );

	// m_realtime
	for( int i=0; i<RTV_MAX_MULTICOUNT; i++ )
		m_realtime[i].SetParent( this );

	// 实时行情刷新
	AfxGetStkReceiver().AddRcvDataWnd( GetSafeHwnd() );

	// 大单成交刷新
	SetTimer( RTV_TIMER_REFRESHBIGTRADE, 30000, NULL );
	SetTimer( RTV_TIMER_REFRESH, 30000, NULL );

	return 0;
}

void CRealTimeView::OnSelchangeReporttab(NMHDR* pNMHDR, LRESULT* pResult) 
{
	if( 1 != m_nMultiStockCount )
		return;

	int nCur = m_wndReportTab.GetCurtab();
	CRect	rect = m_wndReportTab.GetTabRect( nCur );

	int nTechLine = m_realtime[0].GetDrawTechLine();
	switch( nCur )
	{
	case RT_REPORTTAB_QUOTE:
		m_realtime[0].SetDrawMode( CRealTime::modePriceLine, nTechLine, CRealTime::reportQuote );
		break;
	case RT_REPORTTAB_PRICE:
		m_realtime[0].SetDrawMode( CRealTime::modePriceLine, nTechLine, CRealTime::reportPrice );
		break;
	case RT_REPORTTAB_MINUTE:
		m_realtime[0].SetDrawMode( CRealTime::modePriceLine, nTechLine, CRealTime::reportMinute );
		break;
	case RT_REPORTTAB_BUYSELLEX:
		m_realtime[0].SetDrawMode( CRealTime::modePriceLine, nTechLine, CRealTime::reportBuySellEx );
		break;
	case RT_REPORTTAB_VALUE:
		m_realtime[0].SetDrawMode( CRealTime::modePriceLine, nTechLine, CRealTime::reportValue );
		break;
	case RT_REPORTTAB_DISTRIBUTE:
		m_realtime[0].SetDrawMode( CRealTime::modePriceLine, nTechLine, CRealTime::reportDistribute );
		break;
	case RT_REPORTTAB_BIGTRADE:
		m_realtime[0].SetDrawMode( CRealTime::modePriceLine, nTechLine, CRealTime::reportBigTrade );
		break;
	default:;
	}
	m_realtime[0].DrawReportRegion( NULL );
	
	*pResult = 0;
}

void CRealTimeView::OnWindowPosChanged(WINDOWPOS FAR* lpwndpos) 
{
	CView::OnWindowPosChanged(lpwndpos);

	if( !(lpwndpos->flags & SWP_NOSIZE) || !(lpwndpos->flags & SWP_NOMOVE)
		|| (lpwndpos->flags & SWP_SHOWWINDOW) )
	{
		CRect	rect;
		GetClientRect( &rect );
		if( ::IsWindow(m_wndReportTab.GetSafeHwnd()) )
		{
			if( 1 == m_nMultiStockCount && CRealTime::modePriceLine == m_realtime[0].GetDrawMode() )
				m_wndReportTab.SetWindowPos( NULL, rect.right-200, rect.bottom-19, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW );
			else
				m_wndReportTab.SetWindowPos( NULL, rect.right-200, rect.bottom-19, 0, 0, SWP_NOSIZE | SWP_HIDEWINDOW );
		}
	}
}

void CRealTimeView::OnDestroy() 
{
	// 停止行情刷新通知消息
	AfxGetStkReceiver().RemoveRcvDataWnd( GetSafeHwnd() );
	KillTimer( RTV_TIMER_REFRESHBIGTRADE );
	KillTimer( RTV_TIMER_REFRESH );

	CView::OnDestroy();
}

void CRealTimeView::OnTimer(UINT nIDEvent) 
{
	if( RTV_TIMER_REFRESHBIGTRADE == nIDEvent )
	{
		int	nDrawMode	=	m_realtime[0].GetDrawMode();
		int	nReportWhat	=	m_realtime[0].GetReportWhat();

		if( CRealTime::modeBigTradeDetail == nDrawMode )
			Invalidate( );
		else if( CRealTime::modePriceLine == nDrawMode
			&& CRealTime::reportBigTrade == nReportWhat )
			m_realtime[0].DrawReportRegion( NULL );
	}
	if( RTV_TIMER_REFRESH == nIDEvent )
	{
		SendRequestQuote(FALSE);
	}

	CView::OnTimer(nIDEvent);
}

void CRealTimeView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView) 
{
	// TODO: Add your specialized code here and/or call the base class
	if( bActivate )
		OnUpdate( NULL, UPDATE_HINT_REALTIMEVIEW, NULL );

	CView::OnActivateView(bActivate, pActivateView, pDeactiveView);
}

BOOL CRealTimeView::OnEraseBkgnd(CDC* pDC) 
{
	// TODO: Add your message handler code here and/or call default
	if( pDC && pDC->IsKindOf(RUNTIME_CLASS(CDC)) )
	{
		CRect rect;
		GetClientRect( &rect );
		CBrush brush;
		brush.CreateSolidBrush( AfxGetProfile().GetColor(CColorClass::clrGraphBK) );
		pDC->FillRect( &rect, &brush );
		return TRUE;
	}
	return CView::OnEraseBkgnd(pDC);
}

LRESULT CRealTimeView::OnGetViewTitle(WPARAM wParam, LPARAM lParam)
{
	CString	strTitle;
	strTitle.LoadString( IDS_TITLE_REALTIMEVIEW );

	lstrcpyn((LPTSTR)lParam, (LPCTSTR)strTitle, wParam);
	if ((int)wParam > strTitle.GetLength())
		wParam = strTitle.GetLength();
	return wParam;
}

LRESULT CRealTimeView::OnGetViewCmdid(WPARAM wParam, LPARAM lParam)
{
	if( lParam )
		*((LPARAM *)lParam)	=	ID_VIEW_REALTIME;
	return 0L;
}

LRESULT CRealTimeView::OnColorChange(WPARAM wParam, LPARAM lParam)
{
	m_wndReportTab.SetColorTabs(AfxGetProfile().GetColor(CColorClass::clrGraphBK));
	m_wndReportTab.SetSelectTabColor( AfxGetProfile().GetColor(CColorClass::clrGraphBK),
									AfxGetProfile().GetColor(CColorClass::clrTitle) );
	m_wndReportTab.Invalidate( );

	Invalidate( );
	return 0L;
}

LRESULT CRealTimeView::OnStkReceiverData(WPARAM wParam, LPARAM lParam)
{
	for( int i=0; i<m_nMultiStockCount && i<RTV_MAX_MULTICOUNT; i++ )
		m_realtime[i].OnStkReceiverData(wParam,lParam);
	return 0;
}

void CRealTimeView::OnLButtonDown(UINT nFlags, CPoint point) 
{
	for( int i=0; i<m_nMultiStockCount && i<RTV_MAX_MULTICOUNT; i++ )
		m_realtime[i].OnLButtonDown( nFlags, point, IsSHIFTpressed(), IsCTRLpressed() );
	CView::OnLButtonDown(nFlags, point);
}

void CRealTimeView::OnLButtonUp(UINT nFlags, CPoint point) 
{
	CView::OnLButtonUp(nFlags, point);
}

void CRealTimeView::OnLButtonDblClk(UINT nFlags, CPoint point) 
{
	for( int i=0; i<m_nMultiStockCount && i<RTV_MAX_MULTICOUNT; i++ )
		m_realtime[i].OnLButtonDblClk( nFlags, point );
	CView::OnLButtonDblClk(nFlags, point);
}

void CRealTimeView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	switch( nChar )
	{
	case VK_LEFT:
		OnRealtimeLeft();
		break;
	case VK_RIGHT:
		OnRealtimeRight();
		break;
	case VK_UP:
		OnRealtimeUp();
		break;
	case VK_DOWN:
		OnRealtimeDown();
		break;
	case VK_HOME:
		OnRealtimeHome();
		break;
	case VK_END:
		OnRealtimeEnd();
		break;
	case VK_PRIOR:	//	Page Up
		OnRealtimePrev( );
		break;
	case VK_NEXT:	//	Page Down
		OnRealtimeNext( );
		break;
	case VK_ESCAPE:
		if (m_realtime[0].GetDrawMode() != CRealTime::modePriceLine)
		{
			ChangeDrawMode(CRealTime::modePriceLine);
		}
		for( int i=0; i<m_nMultiStockCount && i<RTV_MAX_MULTICOUNT; i++ )
			m_realtime[i].ResetIndexCurrent( );
		Invalidate( );
		break;
	}

	CView::OnKeyDown(nChar, nRepCnt, nFlags);
}

void CRealTimeView::OnRealtimePrev() 
{
	if( CRealTime::modePriceLine == m_realtime[0].GetDrawMode() )
	{
		CStockInfo	info;
		for( int i=0; i<m_nMultiStockCount && i<RTV_MAX_MULTICOUNT; i++ )
			AfxGetProfile().GetPrevStock( &info );
		OnUpdate( NULL, UPDATE_HINT_REALTIMEVIEW, NULL );
	}
	for( int i=0; i<m_nMultiStockCount && i<RTV_MAX_MULTICOUNT; i++ )
		m_realtime[i].PageUp( );
}

void CRealTimeView::OnRealtimeNext() 
{
	if( CRealTime::modePriceLine == m_realtime[0].GetDrawMode() )
	{
		CStockInfo	info;
		for( int i=0; i<m_nMultiStockCount && i<RTV_MAX_MULTICOUNT; i++ )
			AfxGetProfile().GetNextStock( &info );
		OnUpdate( NULL, UPDATE_HINT_REALTIMEVIEW, NULL );
	}
	for( int i=0; i<m_nMultiStockCount && i<RTV_MAX_MULTICOUNT; i++ )
		m_realtime[i].PageDown( );
}

void CRealTimeView::OnRealtimeLeft() 
{
	for( int i=0; i<m_nMultiStockCount && i<RTV_MAX_MULTICOUNT; i++ )
		m_realtime[i].MoveLeft( );
}

void CRealTimeView::OnRealtimeRight() 
{
	for( int i=0; i<m_nMultiStockCount && i<RTV_MAX_MULTICOUNT; i++ )
		m_realtime[i].MoveRight( );
}

void CRealTimeView::OnRealtimeUp() 
{
	for( int i=0; i<m_nMultiStockCount && i<RTV_MAX_MULTICOUNT; i++ )
		m_realtime[i].MoveUp( );
}

void CRealTimeView::OnRealtimeDown() 
{
	for( int i=0; i<m_nMultiStockCount && i<RTV_MAX_MULTICOUNT; i++ )
		m_realtime[i].MoveDown( );
}

void CRealTimeView::OnRealtimeHome() 
{
	for( int i=0; i<m_nMultiStockCount && i<RTV_MAX_MULTICOUNT; i++ )
		m_realtime[i].MoveHome( );
}

void CRealTimeView::OnRealtimeEnd() 
{
	for( int i=0; i<m_nMultiStockCount && i<RTV_MAX_MULTICOUNT; i++ )
		m_realtime[i].MoveEnd( );
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -