RealTimeView.cpp
上传用户:zhanglf88
上传日期:2013-11-19
资源大小:6036k
文件大小:19k
源码类别:

金融证券系统

开发平台:

Visual C++

  1. // RealTimeView.cpp : implementation of the CRealTimeView class
  2. //
  3. #include "stdafx.h"
  4. #include "../StaticDoc.h"
  5. #include "RealTimeView.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CRealTimeView
  13. #define RTV_TIMER_REFRESHBIGTRADE 1
  14. #define RTV_TIMER_REFRESH 2
  15. #define IDC_REALTIMEVIEW_REPORTTAB 200
  16. #define RT_REPORTTAB_QUOTE 0 // 笔
  17. #define RT_REPORTTAB_PRICE 1 // 价
  18. #define RT_REPORTTAB_MINUTE 2 // 分
  19. #define RT_REPORTTAB_BUYSELLEX 3 // 盘
  20. #define RT_REPORTTAB_VALUE 4 // 值
  21. #define RT_REPORTTAB_DISTRIBUTE 5 // 筹
  22. #define RT_REPORTTAB_BIGTRADE 6 // 单
  23. IMPLEMENT_DYNCREATE(CRealTimeView, CView)
  24. BEGIN_MESSAGE_MAP(CRealTimeView, CView)
  25. //{{AFX_MSG_MAP(CRealTimeView)
  26. ON_WM_CREATE()
  27. ON_WM_WINDOWPOSCHANGED()
  28. ON_WM_DESTROY()
  29. ON_WM_TIMER()
  30. ON_WM_ERASEBKGND()
  31. ON_WM_LBUTTONDOWN()
  32. ON_WM_LBUTTONUP()
  33. ON_WM_LBUTTONDBLCLK()
  34. ON_WM_KEYDOWN()
  35. ON_COMMAND(ID_REALTIME_PREV, OnRealtimePrev)
  36. ON_COMMAND(ID_REALTIME_NEXT, OnRealtimeNext)
  37. ON_COMMAND(ID_REALTIME_LEFT, OnRealtimeLeft)
  38. ON_COMMAND(ID_REALTIME_RIGHT, OnRealtimeRight)
  39. ON_COMMAND(ID_REALTIME_HOME, OnRealtimeHome)
  40. ON_COMMAND(ID_REALTIME_END, OnRealtimeEnd)
  41. ON_NOTIFY(TCN_SELCHANGE, IDC_REALTIMEVIEW_REPORTTAB, OnSelchangeReporttab)
  42. //}}AFX_MSG_MAP
  43. // Standard printing commands
  44. ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
  45. ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
  46. ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
  47. ON_MESSAGE(WM_USER_GETVIEWTITLE, OnGetViewTitle)
  48. ON_MESSAGE(WM_USER_GETVIEWCMDID, OnGetViewCmdid)
  49. ON_MESSAGE(WM_USER_COLORCHANGE, OnColorChange)
  50. ON_MESSAGE(WM_APP_STKRECEIVER_DATA, OnStkReceiverData)
  51. END_MESSAGE_MAP()
  52. /////////////////////////////////////////////////////////////////////////////
  53. // CRealTimeView construction/destruction
  54. CRealTimeView::CRealTimeView()
  55. {
  56. m_nMultiStockCount = 1;
  57. ASSERT( RTV_MAX_MULTICOUNT > 0 );
  58. }
  59. CRealTimeView::~CRealTimeView()
  60. {
  61. }
  62. void CRealTimeView::ShowMultiStock( int nMultiStockCount )
  63. {
  64. ASSERT( 1 == nMultiStockCount || 2 == nMultiStockCount
  65. || 4 == nMultiStockCount || 6 == nMultiStockCount
  66. || 9 == nMultiStockCount );
  67. if( 1 != nMultiStockCount && 2 != nMultiStockCount
  68. && 4 != nMultiStockCount && 6 != nMultiStockCount
  69. && 9 != nMultiStockCount )
  70. return;
  71. if( nMultiStockCount == m_nMultiStockCount )
  72. return;
  73. m_nMultiStockCount = nMultiStockCount;
  74. int nDrawMode = m_realtime[0].GetDrawMode();
  75. int nTechLine = m_realtime[0].GetDrawTechLine();
  76. int nReportWhat = m_realtime[0].GetReportWhat();
  77. if( 1 == m_nMultiStockCount )
  78. {
  79. for( int i=0; i<RTV_MAX_MULTICOUNT; i++ )
  80. m_realtime[i].SetDrawMode( nDrawMode, nTechLine, CRealTime::reportQuote );
  81. m_wndReportTab.SetCurtab( RT_REPORTTAB_QUOTE );
  82. }
  83. else
  84. {
  85. for( int i=0; i<RTV_MAX_MULTICOUNT; i++ )
  86. m_realtime[i].SetDrawMode( CRealTime::modePriceLine, CRealTime::techNone, CRealTime::reportNone );
  87. }
  88. OnUpdate( NULL, UPDATE_HINT_REALTIMEVIEW, NULL );
  89. }
  90. void CRealTimeView::ChangeDrawMode( int nDrawMode )
  91. {
  92. int nTechLine = m_realtime[0].GetDrawTechLine();
  93. int nReportWhat = m_realtime[0].GetReportWhat();
  94. for( int i=0; i<m_nMultiStockCount && i<RTV_MAX_MULTICOUNT; i++ )
  95. m_realtime[i].SetDrawMode( nDrawMode, nTechLine, nReportWhat );
  96. if( ::IsWindow(m_wndReportTab.GetSafeHwnd()) )
  97. {
  98. if( 1 == m_nMultiStockCount && CRealTime::modePriceLine == nDrawMode )
  99. m_wndReportTab.SetWindowPos( NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW );
  100. else
  101. m_wndReportTab.SetWindowPos( NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_HIDEWINDOW );
  102. }
  103. Invalidate();
  104. }
  105. void CRealTimeView::ToggleDrawTechLine( int nTechLine )
  106. {
  107. int nOld = m_realtime[0].GetDrawTechLine();
  108. int nNew = (nTechLine == nOld ? CRealTime::techNone : nTechLine);
  109. int nDrawMode = m_realtime[0].GetDrawMode();
  110. int nReportWhat = m_realtime[0].GetReportWhat();
  111. for( int i=0; i<m_nMultiStockCount && i<RTV_MAX_MULTICOUNT; i++ )
  112. m_realtime[i].SetDrawMode( nDrawMode, nNew, nReportWhat );
  113. Invalidate();
  114. }
  115. void CRealTimeView::SendRequestQuote( BOOL bForced )
  116. {
  117. BOOL bInTrade = CSPTime::InTradeTime(CSPTime::GetCurrentTime().GetTime(),900);
  118. CView * pView = AfxGetStaticDoc()->GetActiveView();
  119. if( bForced || (bInTrade && pView == this) )
  120. {
  121. for( int i=0; i<m_nMultiStockCount && i<RTV_MAX_MULTICOUNT; i++ )
  122. {
  123. CStock & stock = m_realtime[i].GetCurStock( );
  124. CStockInfo & info = stock.GetStockInfo();
  125. if( info.IsValidStock() )
  126. AfxGetStkReceiver().RequestStockData( CStock::dataReport, &info, 1, 0, 0 );
  127. }
  128. }
  129. }
  130. BOOL CRealTimeView::PreCreateWindow(CREATESTRUCT& cs)
  131. {
  132. // TODO: Modify the Window class or styles here by modifying
  133. //  the CREATESTRUCT cs
  134. return CView::PreCreateWindow(cs);
  135. }
  136. void CRealTimeView::OnInitialUpdate() 
  137. {
  138. CView::OnInitialUpdate();
  139. // TODO: Add your specialized code here and/or call the base class
  140. OnUpdate( NULL, UPDATE_HINT_REALTIMEVIEW, NULL );
  141. }
  142. void CRealTimeView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) 
  143. {
  144. // TODO: Add your specialized code here and/or call the base class
  145. if( UPDATE_HINT_REALTIMEVIEW != lHint )
  146. return;
  147. if( !IsWindowVisible() )
  148. return;
  149. SetFocus( );
  150. ASSERT( RTV_MAX_MULTICOUNT > 0 );
  151. CStockInfo info;
  152. if( AfxGetProfile().GetCurrentStock( &info ) )
  153. {
  154. m_realtime[0].SetCurStock( info );
  155. m_realtime[0].PrepareStockData( );
  156. }
  157. else
  158. {
  159. m_realtime[0].SetCurStock( STKLIB_CODE_MAIN );
  160. m_realtime[0].PrepareStockData( );
  161. AfxGetProfile().SetCurrentStock( STKLIB_CODE_MAIN, FALSE );
  162. }
  163. if( CRealTime::modeReportDetail == m_realtime[0].GetDrawMode() )
  164. AfxGetStkReceiver().RequestStockData( CStock::dataDetail, &info, 1, 0, 0 );
  165. else
  166. AfxGetStkReceiver().RequestStockData( CStock::dataMinute, &info, 1, 0, 0 );
  167. // 多股同列
  168. for( int i=1; i<m_nMultiStockCount && i<RTV_MAX_MULTICOUNT; i++ )
  169. {
  170. if( AfxGetProfile().GetNextStock( &info ) )
  171. {
  172. m_realtime[i].SetCurStock( info );
  173. m_realtime[i].PrepareStockData( );
  174. if( CRealTime::modeReportDetail == m_realtime[0].GetDrawMode() )
  175. AfxGetStkReceiver().RequestStockData( CStock::dataDetail, &info, 1, 0, 0 );
  176. else
  177. AfxGetStkReceiver().RequestStockData( CStock::dataMinute, &info, 1, 0, 0 );
  178. }
  179. }
  180. for( i=1; i<m_nMultiStockCount && i<RTV_MAX_MULTICOUNT; i++ )
  181. AfxGetProfile().GetPrevStock( &info );
  182. Invalidate( );
  183. if( 1 == m_nMultiStockCount && CRealTime::modePriceLine == m_realtime[0].GetDrawMode() )
  184. m_wndReportTab.SetWindowPos( NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW );
  185. else
  186. m_wndReportTab.SetWindowPos( NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_HIDEWINDOW );
  187. CMainFrame * pFrame = AfxGetMainFrame();
  188. if( pFrame )
  189. pFrame->m_SearchBox.SetCurrentWindowText( );
  190. SendRequestQuote(TRUE);
  191. }
  192. /////////////////////////////////////////////////////////////////////////////
  193. // CRealTimeView drawing
  194. void CRealTimeView::OnDraw(CDC* pDC)
  195. {
  196. CStaticDoc* pDoc = GetDocument();
  197. ASSERT_VALID(pDoc);
  198. // TODO: add draw code for native data here
  199. CRect rectClient;
  200. GetClientRect( &rectClient );
  201. RedrawAll( pDC, rectClient );
  202. }
  203. void CRealTimeView::RedrawAll( CDC * pDC, CRect rectClient )
  204. {
  205. int i = 0;
  206. CRect rect[RTV_MAX_MULTICOUNT];
  207. for( i=0; i<RTV_MAX_MULTICOUNT; i++ )
  208. rect[i] = rectClient;
  209. switch( m_nMultiStockCount )
  210. {
  211. case 2:
  212. rect[0].bottom = rect[1].top = rectClient.top + rectClient.Height()/2;
  213. for( i=0; i<m_nMultiStockCount; i++ )
  214. m_realtime[i].Redraw( pDC, rect[i] );
  215. break;
  216. case 4:
  217. rect[0].bottom = rect[2].bottom = rect[1].top = rect[3].top = rectClient.top + rectClient.Height()/2;
  218. rect[0].right = rect[1].right = rect[2].left = rect[3].left = rectClient.left + rectClient.Width()/2;
  219. for( i=0; i<m_nMultiStockCount; i++ )
  220. m_realtime[i].Redraw( pDC, rect[i] );
  221. break;
  222. case 6:
  223. rect[0].bottom = rect[3].bottom = rect[1].top = rect[4].top = rectClient.top + rectClient.Height()/3;
  224. rect[1].bottom = rect[4].bottom = rect[2].top = rect[5].top = rectClient.top + 2*rectClient.Height()/3;
  225. rect[0].right = rect[1].right = rect[2].right = rect[3].left = rect[4].left = rect[5].left = rectClient.left + rectClient.Width()/2;
  226. for( i=0; i<m_nMultiStockCount; i++ )
  227. m_realtime[i].Redraw( pDC, rect[i] );
  228. break;
  229. case 9:
  230. rect[0].bottom = rect[3].bottom = rect[6].bottom = rect[1].top = rect[4].top = rect[7].top = rectClient.top + rectClient.Height()/3;
  231. rect[1].bottom = rect[4].bottom = rect[7].bottom = rect[2].top = rect[5].top = rect[8].top = rectClient.top + 2*rectClient.Height()/3;
  232. rect[0].right = rect[1].right = rect[2].right = rect[3].left = rect[4].left = rect[5].left = rectClient.left + rectClient.Width()/3;
  233. rect[3].right = rect[4].right = rect[5].right = rect[6].left = rect[7].left = rect[8].left = rectClient.left + 2*rectClient.Width()/3;
  234. for( i=0; i<m_nMultiStockCount; i++ )
  235. m_realtime[i].Redraw( pDC, rect[i] );
  236. break;
  237. default:
  238. m_realtime[0].Redraw( pDC, rectClient ); // 单股
  239. }
  240. }
  241. /////////////////////////////////////////////////////////////////////////////
  242. // CRealTimeView printing
  243. BOOL CRealTimeView::OnPreparePrinting(CPrintInfo* pInfo)
  244. {
  245. // default preparation
  246. return DoPreparePrinting(pInfo);
  247. }
  248. void CRealTimeView::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo)
  249. {
  250. // TODO: add extra initialization before printing
  251. CView::OnBeginPrinting( pDC, pInfo );
  252. }
  253. void CRealTimeView::OnEndPrinting(CDC* pDC, CPrintInfo* pInfo)
  254. {
  255. // TODO: add cleanup after printing
  256. CView::OnEndPrinting( pDC, pInfo );
  257. }
  258. void CRealTimeView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
  259. {
  260. // TODO: add customized printing code here
  261. pDC->SetMapMode( MM_ISOTROPIC );
  262. CRect rectClient( 0, 0, 1020, 586 );
  263. // GetClientRect( &rectClient );
  264. pDC->SetWindowOrg( rectClient.left, rectClient.top );
  265. pDC->SetWindowExt( rectClient.Width(), rectClient.Height() );
  266. pDC->SetViewportOrg( pInfo->m_rectDraw.left, pInfo->m_rectDraw.top );
  267. pDC->SetViewportExt( pInfo->m_rectDraw.Width(), pInfo->m_rectDraw.Height() );
  268. RedrawAll( pDC, rectClient );
  269. // CView::OnPrint(pDC,pInfo);
  270. }
  271. /////////////////////////////////////////////////////////////////////////////
  272. // CRealTimeView diagnostics
  273. #ifdef _DEBUG
  274. void CRealTimeView::AssertValid() const
  275. {
  276. CView::AssertValid();
  277. }
  278. void CRealTimeView::Dump(CDumpContext& dc) const
  279. {
  280. CView::Dump(dc);
  281. }
  282. #endif //_DEBUG
  283. /////////////////////////////////////////////////////////////////////////////
  284. // CRealTimeView message handlers
  285. int CRealTimeView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
  286. {
  287. if (CView::OnCreate(lpCreateStruct) == -1)
  288. return -1;
  289. CFont font;
  290. if( !font.CreateStockObject( DEFAULT_GUI_FONT ) )
  291. font.CreateStockObject( ANSI_VAR_FONT );
  292. SetFont( &font );
  293. // tab
  294. if (!m_wndReportTab.Create(WS_VISIBLE|WS_CHILD,CRect(0,0,180,19),this,IDC_REALTIMEVIEW_REPORTTAB))
  295. return -1;
  296. CString strName;
  297. strName.LoadString( IDS_REALTIMETAB_QUOTE );
  298. m_wndReportTab.Addtab( this, strName, -1);
  299. strName.LoadString( IDS_REALTIMETAB_PRICE );
  300. m_wndReportTab.Addtab( this, strName, -1);
  301. strName.LoadString( IDS_REALTIMETAB_MINUTE );
  302. m_wndReportTab.Addtab( this, strName, -1);
  303. strName.LoadString( IDS_REALTIMETAB_BUYSELLEX );
  304. m_wndReportTab.Addtab( this, strName, -1);
  305. strName.LoadString( IDS_REALTIMETAB_VALUE );
  306. m_wndReportTab.Addtab( this, strName, -1);
  307. strName.LoadString( IDS_REALTIMETAB_DISTRIBUTE );
  308. m_wndReportTab.Addtab( this, strName, -1);
  309. strName.LoadString( IDS_REALTIMETAB_BIGTRADE );
  310. m_wndReportTab.Addtab( this, strName, -1);
  311. m_wndReportTab.SetColorTabs(AfxGetProfile().GetColor(CColorClass::clrGraphBK));
  312. m_wndReportTab.SetSelectTabColor( AfxGetProfile().GetColor(CColorClass::clrGraphBK),
  313. AfxGetProfile().GetColor(CColorClass::clrTitle) );
  314. m_wndReportTab.SetAutoAjust(FALSE);
  315. m_wndReportTab.ShowButtonClose(FALSE);
  316. m_wndReportTab.SetALingTabs( CGuiTabWnd::ALN_BOTTOM );
  317. // m_realtime
  318. for( int i=0; i<RTV_MAX_MULTICOUNT; i++ )
  319. m_realtime[i].SetParent( this );
  320. // 实时行情刷新
  321. AfxGetStkReceiver().AddRcvDataWnd( GetSafeHwnd() );
  322. // 大单成交刷新
  323. SetTimer( RTV_TIMER_REFRESHBIGTRADE, 30000, NULL );
  324. SetTimer( RTV_TIMER_REFRESH, 30000, NULL );
  325. return 0;
  326. }
  327. void CRealTimeView::OnSelchangeReporttab(NMHDR* pNMHDR, LRESULT* pResult) 
  328. {
  329. if( 1 != m_nMultiStockCount )
  330. return;
  331. int nCur = m_wndReportTab.GetCurtab();
  332. CRect rect = m_wndReportTab.GetTabRect( nCur );
  333. int nTechLine = m_realtime[0].GetDrawTechLine();
  334. switch( nCur )
  335. {
  336. case RT_REPORTTAB_QUOTE:
  337. m_realtime[0].SetDrawMode( CRealTime::modePriceLine, nTechLine, CRealTime::reportQuote );
  338. break;
  339. case RT_REPORTTAB_PRICE:
  340. m_realtime[0].SetDrawMode( CRealTime::modePriceLine, nTechLine, CRealTime::reportPrice );
  341. break;
  342. case RT_REPORTTAB_MINUTE:
  343. m_realtime[0].SetDrawMode( CRealTime::modePriceLine, nTechLine, CRealTime::reportMinute );
  344. break;
  345. case RT_REPORTTAB_BUYSELLEX:
  346. m_realtime[0].SetDrawMode( CRealTime::modePriceLine, nTechLine, CRealTime::reportBuySellEx );
  347. break;
  348. case RT_REPORTTAB_VALUE:
  349. m_realtime[0].SetDrawMode( CRealTime::modePriceLine, nTechLine, CRealTime::reportValue );
  350. break;
  351. case RT_REPORTTAB_DISTRIBUTE:
  352. m_realtime[0].SetDrawMode( CRealTime::modePriceLine, nTechLine, CRealTime::reportDistribute );
  353. break;
  354. case RT_REPORTTAB_BIGTRADE:
  355. m_realtime[0].SetDrawMode( CRealTime::modePriceLine, nTechLine, CRealTime::reportBigTrade );
  356. break;
  357. default:;
  358. }
  359. m_realtime[0].DrawReportRegion( NULL );
  360. *pResult = 0;
  361. }
  362. void CRealTimeView::OnWindowPosChanged(WINDOWPOS FAR* lpwndpos) 
  363. {
  364. CView::OnWindowPosChanged(lpwndpos);
  365. if( !(lpwndpos->flags & SWP_NOSIZE) || !(lpwndpos->flags & SWP_NOMOVE)
  366. || (lpwndpos->flags & SWP_SHOWWINDOW) )
  367. {
  368. CRect rect;
  369. GetClientRect( &rect );
  370. if( ::IsWindow(m_wndReportTab.GetSafeHwnd()) )
  371. {
  372. if( 1 == m_nMultiStockCount && CRealTime::modePriceLine == m_realtime[0].GetDrawMode() )
  373. m_wndReportTab.SetWindowPos( NULL, rect.right-200, rect.bottom-19, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW );
  374. else
  375. m_wndReportTab.SetWindowPos( NULL, rect.right-200, rect.bottom-19, 0, 0, SWP_NOSIZE | SWP_HIDEWINDOW );
  376. }
  377. }
  378. }
  379. void CRealTimeView::OnDestroy() 
  380. {
  381. // 停止行情刷新通知消息
  382. AfxGetStkReceiver().RemoveRcvDataWnd( GetSafeHwnd() );
  383. KillTimer( RTV_TIMER_REFRESHBIGTRADE );
  384. KillTimer( RTV_TIMER_REFRESH );
  385. CView::OnDestroy();
  386. }
  387. void CRealTimeView::OnTimer(UINT nIDEvent) 
  388. {
  389. if( RTV_TIMER_REFRESHBIGTRADE == nIDEvent )
  390. {
  391. int nDrawMode = m_realtime[0].GetDrawMode();
  392. int nReportWhat = m_realtime[0].GetReportWhat();
  393. if( CRealTime::modeBigTradeDetail == nDrawMode )
  394. Invalidate( );
  395. else if( CRealTime::modePriceLine == nDrawMode
  396. && CRealTime::reportBigTrade == nReportWhat )
  397. m_realtime[0].DrawReportRegion( NULL );
  398. }
  399. if( RTV_TIMER_REFRESH == nIDEvent )
  400. {
  401. SendRequestQuote(FALSE);
  402. }
  403. CView::OnTimer(nIDEvent);
  404. }
  405. void CRealTimeView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView) 
  406. {
  407. // TODO: Add your specialized code here and/or call the base class
  408. if( bActivate )
  409. OnUpdate( NULL, UPDATE_HINT_REALTIMEVIEW, NULL );
  410. CView::OnActivateView(bActivate, pActivateView, pDeactiveView);
  411. }
  412. BOOL CRealTimeView::OnEraseBkgnd(CDC* pDC) 
  413. {
  414. // TODO: Add your message handler code here and/or call default
  415. if( pDC && pDC->IsKindOf(RUNTIME_CLASS(CDC)) )
  416. {
  417. CRect rect;
  418. GetClientRect( &rect );
  419. CBrush brush;
  420. brush.CreateSolidBrush( AfxGetProfile().GetColor(CColorClass::clrGraphBK) );
  421. pDC->FillRect( &rect, &brush );
  422. return TRUE;
  423. }
  424. return CView::OnEraseBkgnd(pDC);
  425. }
  426. LRESULT CRealTimeView::OnGetViewTitle(WPARAM wParam, LPARAM lParam)
  427. {
  428. CString strTitle;
  429. strTitle.LoadString( IDS_TITLE_REALTIMEVIEW );
  430. lstrcpyn((LPTSTR)lParam, (LPCTSTR)strTitle, wParam);
  431. if ((int)wParam > strTitle.GetLength())
  432. wParam = strTitle.GetLength();
  433. return wParam;
  434. }
  435. LRESULT CRealTimeView::OnGetViewCmdid(WPARAM wParam, LPARAM lParam)
  436. {
  437. if( lParam )
  438. *((LPARAM *)lParam) = ID_VIEW_REALTIME;
  439. return 0L;
  440. }
  441. LRESULT CRealTimeView::OnColorChange(WPARAM wParam, LPARAM lParam)
  442. {
  443. m_wndReportTab.SetColorTabs(AfxGetProfile().GetColor(CColorClass::clrGraphBK));
  444. m_wndReportTab.SetSelectTabColor( AfxGetProfile().GetColor(CColorClass::clrGraphBK),
  445. AfxGetProfile().GetColor(CColorClass::clrTitle) );
  446. m_wndReportTab.Invalidate( );
  447. Invalidate( );
  448. return 0L;
  449. }
  450. LRESULT CRealTimeView::OnStkReceiverData(WPARAM wParam, LPARAM lParam)
  451. {
  452. for( int i=0; i<m_nMultiStockCount && i<RTV_MAX_MULTICOUNT; i++ )
  453. m_realtime[i].OnStkReceiverData(wParam,lParam);
  454. return 0;
  455. }
  456. void CRealTimeView::OnLButtonDown(UINT nFlags, CPoint point) 
  457. {
  458. for( int i=0; i<m_nMultiStockCount && i<RTV_MAX_MULTICOUNT; i++ )
  459. m_realtime[i].OnLButtonDown( nFlags, point, IsSHIFTpressed(), IsCTRLpressed() );
  460. CView::OnLButtonDown(nFlags, point);
  461. }
  462. void CRealTimeView::OnLButtonUp(UINT nFlags, CPoint point) 
  463. {
  464. CView::OnLButtonUp(nFlags, point);
  465. }
  466. void CRealTimeView::OnLButtonDblClk(UINT nFlags, CPoint point) 
  467. {
  468. for( int i=0; i<m_nMultiStockCount && i<RTV_MAX_MULTICOUNT; i++ )
  469. m_realtime[i].OnLButtonDblClk( nFlags, point );
  470. CView::OnLButtonDblClk(nFlags, point);
  471. }
  472. void CRealTimeView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
  473. {
  474. switch( nChar )
  475. {
  476. case VK_LEFT:
  477. OnRealtimeLeft();
  478. break;
  479. case VK_RIGHT:
  480. OnRealtimeRight();
  481. break;
  482. case VK_UP:
  483. OnRealtimeUp();
  484. break;
  485. case VK_DOWN:
  486. OnRealtimeDown();
  487. break;
  488. case VK_HOME:
  489. OnRealtimeHome();
  490. break;
  491. case VK_END:
  492. OnRealtimeEnd();
  493. break;
  494. case VK_PRIOR: // Page Up
  495. OnRealtimePrev( );
  496. break;
  497. case VK_NEXT: // Page Down
  498. OnRealtimeNext( );
  499. break;
  500. case VK_ESCAPE:
  501. for( int i=0; i<m_nMultiStockCount && i<RTV_MAX_MULTICOUNT; i++ )
  502. m_realtime[i].ResetIndexCurrent( );
  503. Invalidate( );
  504. break;
  505. }
  506. CView::OnKeyDown(nChar, nRepCnt, nFlags);
  507. }
  508. void CRealTimeView::OnRealtimePrev() 
  509. {
  510. if( CRealTime::modePriceLine == m_realtime[0].GetDrawMode() )
  511. {
  512. CStockInfo info;
  513. for( int i=0; i<m_nMultiStockCount && i<RTV_MAX_MULTICOUNT; i++ )
  514. AfxGetProfile().GetPrevStock( &info );
  515. OnUpdate( NULL, UPDATE_HINT_REALTIMEVIEW, NULL );
  516. }
  517. for( int i=0; i<m_nMultiStockCount && i<RTV_MAX_MULTICOUNT; i++ )
  518. m_realtime[i].PageUp( );
  519. }
  520. void CRealTimeView::OnRealtimeNext() 
  521. {
  522. if( CRealTime::modePriceLine == m_realtime[0].GetDrawMode() )
  523. {
  524. CStockInfo info;
  525. for( int i=0; i<m_nMultiStockCount && i<RTV_MAX_MULTICOUNT; i++ )
  526. AfxGetProfile().GetNextStock( &info );
  527. OnUpdate( NULL, UPDATE_HINT_REALTIMEVIEW, NULL );
  528. }
  529. for( int i=0; i<m_nMultiStockCount && i<RTV_MAX_MULTICOUNT; i++ )
  530. m_realtime[i].PageDown( );
  531. }
  532. void CRealTimeView::OnRealtimeLeft() 
  533. {
  534. for( int i=0; i<m_nMultiStockCount && i<RTV_MAX_MULTICOUNT; i++ )
  535. m_realtime[i].MoveLeft( );
  536. }
  537. void CRealTimeView::OnRealtimeRight() 
  538. {
  539. for( int i=0; i<m_nMultiStockCount && i<RTV_MAX_MULTICOUNT; i++ )
  540. m_realtime[i].MoveRight( );
  541. }
  542. void CRealTimeView::OnRealtimeUp() 
  543. {
  544. for( int i=0; i<m_nMultiStockCount && i<RTV_MAX_MULTICOUNT; i++ )
  545. m_realtime[i].MoveUp( );
  546. }
  547. void CRealTimeView::OnRealtimeDown() 
  548. {
  549. for( int i=0; i<m_nMultiStockCount && i<RTV_MAX_MULTICOUNT; i++ )
  550. m_realtime[i].MoveDown( );
  551. }
  552. void CRealTimeView::OnRealtimeHome() 
  553. {
  554. for( int i=0; i<m_nMultiStockCount && i<RTV_MAX_MULTICOUNT; i++ )
  555. m_realtime[i].MoveHome( );
  556. }
  557. void CRealTimeView::OnRealtimeEnd() 
  558. {
  559. for( int i=0; i<m_nMultiStockCount && i<RTV_MAX_MULTICOUNT; i++ )
  560. m_realtime[i].MoveEnd( );
  561. }