入口:
G:\stock\TskingVS2019\src\Client\StkUI\StkUI.rc
/////////////////////////////////////////////////////////////////////////////
//
// Accelerator
//热键、快捷键定义 by freeman
IDR_MAINFRAME ACCELERATORS
BEGIN
"A", ID_EDIT_SELECT_ALL, VIRTKEY, CONTROL, NOINVERT
"B", ID_VIEW_RESUMEDRUP, VIRTKEY, CONTROL, NOINVERT
"C", ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT
"F", ID_EDIT_FIND, VIRTKEY, CONTROL, NOINVERT
"P", ID_FILE_PRINT, VIRTKEY, CONTROL, NOINVERT
"V", ID_VIEW_RESUMEDRDOWN, VIRTKEY, CONTROL, NOINVERT
VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT, NOINVERT
VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT, NOINVERT
VK_F1, ID_REALTIME_REPORTDETAIL, VIRTKEY, NOINVERT
主菜单
MENUITEM SEPARATOR
MENUITEM "分时价格线(&P)", ID_REALTIME_PRICELINE
MENUITEM "每笔成交明细(&B)\tF1", ID_REALTIME_REPORTDETAIL
热键
G:\stock\TskingVS2019\src\Client\StkLib\Include\AfxCore.h
//组合键功能定义 by freeman
#define ACCE_MIN 1
#define ACCE_01 1 // 热键F1
D:\temp\stock\k-line-print-master\client\cnmarket\StkUI\MainFrm.cpp
ON_UPDATE_COMMAND_UI(ID_REALTIME_REPORTDETAIL, OnUpdateRealtimeReportdetail)
void CMainFrame::OnUpdateRealtimeReportdetail(CCmdUI* pCmdUI)
{ CRealTimeView * pView = AfxGetRealTimeView();
pCmdUI->SetCheck( pView && CRealTime::modeReportDetail == pView->GetDrawMode() ); }
D:\temp\stock\k-line-print-master\client\cnmarket\StkUI\View\RealTime.cpp
/////////////////////////////////////////////////////////////////////////////////////////////////////
// 以下为每笔成交明细使用 modeReportDetail
void CRealTime::DrawReportDetail( CDC * pDC )
{
DECLARE_COLOR_DEFINATION
CStockInfo & info = m_CurStock.GetStockInfo();
CReport & aReport = m_CurStock.GetReport();
// set bkcolor
pDC->SetBkColor( clrBK );
// Draw Name And Code
CFont * pOldFont = AfxSelectDCFont( pDC, 18 );
pDC->SetTextColor( clrTitle );
pDC->TextOut( m_rectAll.left+1, m_rectAll.top+3, info.GetStockName() );
pDC->TextOut( m_rectAll.left+96, m_rectAll.top+3, info.GetStockCode() );
// Draw Title
CString strTitle;
strTitle.LoadString( IDS_REALTIME_REPORTDETAILTITLE );
pDC->TextOut( m_rectAll.left+180, m_rectAll.top+3, strTitle );
// Select Report Font
AfxSelectDCFont( pDC, 14 );
// 成交明细
int nColumnPerPage = GetColumnPerPage( m_rectAll );
int nCountPerColumn = GetCountPerColumn( m_rectAll );
int nCountPerPage = nCountPerColumn * nColumnPerPage;
if( nCountPerPage <= 0 )
return;
m_nCurrentStartPos = CheckValidStartPos( m_nCurrentStartPos, aReport.GetSize(), nCountPerPage, TRUE );
int nStartPos = m_nCurrentStartPos;
for( int nColumn=0; nColumn<nColumnPerPage; nColumn ++ )
{
if( nStartPos >= aReport.GetSize() )
break;
CRect rectColumn;
rectColumn.top = m_rectAll.top + RT_RDTITLE_HEIGHT;
rectColumn.bottom = m_rectAll.bottom;
rectColumn.left = m_rectAll.left + nColumn*RT_RDCOLUMN_WIDTH;
rectColumn.right = rectColumn.left + RT_RDCOLUMN_WIDTH;
DrawReportColumn( pDC, info, aReport, nStartPos, nCountPerColumn, rectColumn );
nStartPos += nCountPerColumn;
}
pDC->SelectObject( pOldFont );
}
画成交明细DrawReportColumn()
////////////////////////////////////////////////////////////////////////////
// 函 数 名: CRealTime::DrawReportColumn( CDC * pDC, CStockInfo & info, CReport & aReport, int nStartPos, int nMaxCount, CRect rect )
// 功能说明:实时行情,画右下角成交信息by freeman
// 入口参数:
// 出口参数:
// 返回参数:
////////////////////////////////////////////////////////////////////////////
//RealTime:注释,实时行情,画右下角“笔”成交明细,添加了秒显示
void CRealTime::DrawReportColumn(CDC* pDC, CStockInfo& info, CReport& aReport, int nStartPos, int nMaxCount, CRect rect)
{
DECLARE_COLOR_DEFINATION
int y = rect.top + RT_RDTITLE_HEIGHT;
int x = rect.left + 2;
int x2 = (int)(x + 0.55 * rect.Width());
//int x3 = rect.right-1; // old
int x3 = (int)(x + 0.80 * rect.Width());//add by freeman
int x4 = rect.right - 1; //add by freeman
// Draw Border
pDC->Draw3dRect(&rect, clrBorder, clrBorder);
DrawLine(pDC, 1, clrBorder, rect.left, rect.top + RT_RDTITLE_HEIGHT - 2, rect.right, rect.top + RT_RDTITLE_HEIGHT - 2);
// Set Align
pDC->SetBkColor(clrBK);
UINT nOldAlign = pDC->SetTextAlign(TA_LEFT | TA_TOP);
// Draw Title Text
CString strTemp;
CFont* pOldFont = AfxSelectDCFont(pDC, 14);
pDC->SetTextColor(clrText);
strTemp.LoadString(IDS_REALTIME_TIME);
pDC->TextOut(x + 1, rect.top + 5, strTemp);
pDC->SetTextAlign(TA_RIGHT | TA_TOP);
strTemp.LoadString(IDS_REALTIME_PRICE);
pDC->TextOut(x2 - 1, rect.top + 5, strTemp);
strTemp.LoadString(IDS_REALTIME_VOLUME);
pDC->TextOut(x3 - 1, rect.top + 5, strTemp);
/*********custom extend 交易笔数 by freeman************/
pDC->TextOut(x4 - 1, rect.top + 5, _T("笔数"));
/*******************************************/
// 价格小数位数格式串
CString strPriceFmt;
strPriceFmt.Format("%%.%df", info.DigitBit());
for (int i = nStartPos; i < aReport.GetSize() && i - nStartPos + 1 <= nMaxCount; i++)
{
REPORT report = aReport.ElementAt(i);
// Time
CSPTime time(report.m_time);
CString strTime = time.Format("%H:%M:%S"); //成交明细,修改时间,添加了秒显示
pDC->SetTextColor(clrText);
pDC->SetTextAlign(TA_LEFT | TA_TOP);
pDC->TextOut(x, y + RT_RDELEMENT_HEIGHT * (i - nStartPos), strTime);
// Price
CString strPrice;
strPrice.Format(strPriceFmt, report.m_fNew);
pDC->SetTextColor(RT_DETERMINE_COLOR(report.m_fNew, report.m_fLast));
pDC->SetTextAlign(TA_RIGHT | TA_TOP);
pDC->TextOut(x2, y + RT_RDELEMENT_HEIGHT * (i - nStartPos), strPrice);
// Volume
double dVolume = (i > 0 ? aReport[i].m_fVolume - aReport[i - 1].m_fVolume : aReport[i].m_fVolume);
double dMidPrice = (i > 0 ? (aReport[i - 1].m_fBuyPrice[0] + aReport[i - 1].m_fSellPrice[0]) / 2 : (aReport[i].m_fBuyPrice[0] + aReport[i].m_fSellPrice[0]) / 2);
if (dMidPrice < 1e-4)
dMidPrice = report.m_fLast;
CString strVolume, strUp, strDown;
strUp.LoadString(IDS_SLISTVIEW_UP);
strDown.LoadString(IDS_SLISTVIEW_DOWN);
strVolume.Format("%.0f", dVolume / 100);
if (report.m_fNew - dMidPrice > 1e-4) //算买卖标志,涨跌停时是错的 by freeman
strVolume += strUp;
else if (report.m_fNew - dMidPrice < 1e-4)
strVolume += strDown;
else
strVolume += "-";
pDC->SetTextColor(RT_DETERMINE_COLOR(report.m_fNew, dMidPrice));
pDC->SetTextAlign(TA_RIGHT | TA_TOP);
pDC->TextOut(x3, y + RT_RDELEMENT_HEIGHT * (i - nStartPos), strVolume);
/**************custom extend 成交笔数 by freeman*****************************/
//TotalTradeNumber
double dTotalTradeNumber = (i > 0 ? aReport[i].m_fTotalTradeNumber - aReport[i - 1].m_fTotalTradeNumber : aReport[i].m_fTotalTradeNumber);
CString strTotalTradeNumber;
strTotalTradeNumber.Format("%.0f", dTotalTradeNumber);
pDC->SetTextColor(clrTitle);
pDC->SetTextAlign(TA_RIGHT | TA_TOP);
pDC->TextOut(x4, y + RT_RDELEMENT_HEIGHT * (i - nStartPos), strTotalTradeNumber);
/*******************************************************************/
}
pDC->SetTextAlign(nOldAlign);
pDC->SelectObject(pOldFont);
}