策略为王源代码扩展系列-K线图(2)-为K线图增加板块、股票代码、按键处理、ctrl+M多股同列等信息显示功能

Published

StkLib\Src\Stock.cpp:注释,策略为王的板块和省份数据是从财务数据中获取并填入的

//财务数据
BOOL CStockInfo::StatBaseIndex(DWORD dwDate)
{
	SP_ASSERT(0 != dwDate);

	if (m_basedata.GetSize() == 0)
		return FALSE;

	int	nIndex = m_basedata.GetSize() - 1;
	for (int i = m_basedata.GetSize() - 1; i >= 0; i--)
	{
		if (m_basedata.ElementAt(i).m_date <= dwDate)
		{
			nIndex = i;
			break;
		}
	}

	BASEDATA& block = m_basedata.ElementAt(nIndex);

	//策略为王的板块和省份数据是从财务数据中获取并填入的 by freeman
	strncpy(m_szDomain, block.m_szDomain, min(sizeof(m_szDomain), sizeof(block.m_szDomain)));
	strncpy(m_szProvince, block.m_szProvince, min(sizeof(m_szProvince), sizeof(block.m_szProvince)));
	strncpy(m_szProvince, "block.m_szProvince", min(sizeof(m_szProvince), sizeof(block.m_szProvince)));

StkUI:CStockGraph,按键处理,添加按回车切换到显示分时线

在GraphView.cpp中对按键的消息处理中,按下回车键调用了下面的函数

void CGraphView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	switch( nChar )
	{
	case VK_RETURN:
		m_graph.OnReturn( IsSHIFTpressed(), IsCTRLpressed() );
		break;
 src/Client/StkUI/View/StockGraph.cpp


void CStockGraph::OnReturn(BOOL bShiftPressed, BOOL bCtrlPressed)
{


	/*****custom extend start 回车键处理 by freeman 2019/06/08****/

	{
		AfxSwitchToStaticView(RUNTIME_CLASS(CRealTimeView));
		CRealTimeView* pView = AfxGetRealTimeView();
		if (pView)
			pView->ChangeDrawMode(CRealTime::modePriceLine);
	}
    /**********custom extend end-********************************/

	if (m_nIndexCurrent >= 0)
	{
		CKData& kdata = m_CurStock.GetKData(m_nCurKType);

custom extend CTRL+M 多股同列
G:\stock\TskingVS2019\src\Client\StkUI\View\GraphView.cpp

//按键定义 
void CGraphView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	switch(nChar)
	{
         ..
 /***** custom extend CTRL+M 多股同列by freeman 2019/06/08******/
	case 'M':
		if (IsCTRLpressed())
		{			
				HWND	hWnd = AfxGetMainFrame()->GetSafeHwnd();
				::PostMessage(hWnd, WM_COMMAND, ID_REALTIME_NINESTOCK, 0);			
		}
		break;
		/***** custom end CTRL+M 多股同列by freeman 2019/06/08******/
	}
}