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

金融证券系统

开发平台:

Visual C++

  1. // InfoView.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "../StaticDoc.h"
  5. #include "InfoView.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CInfoView
  13. IMPLEMENT_DYNCREATE(CInfoView, CHtmlView)
  14. CInfoView::CInfoView()
  15. {
  16. //{{AFX_DATA_INIT(CInfoView)
  17. // NOTE: the ClassWizard will add member initialization here
  18. //}}AFX_DATA_INIT
  19. SetCurrentServer( AfxGetProfile().GetInfoCurrentServer( ) );
  20. m_nServerShowed = serverUnknown;
  21. }
  22. CInfoView::~CInfoView()
  23. {
  24. AfxGetProfile().SetInfoCurrentServer( m_nServer );
  25. }
  26. void CInfoView::SetCurrentServer( int nServer )
  27. {
  28. m_nServer = nServer;
  29. if( nServer < serverMin || nServer > serverMax )
  30. m_nServer = serverSelf;
  31. }
  32. int CInfoView::GetCurrentServer( )
  33. {
  34. return m_nServer;
  35. }
  36. void CInfoView::OnRefresh( )
  37. {
  38. OnUpdate( NULL, UPDATE_HINT_INFOVIEW, NULL );
  39. }
  40. char szInfoSelf[] = "http://%s/info/%s/?market=%s&code=%s";
  41. char szInfoF10[] = "http://www.f10.com.cn/ggzx/ggzl.asp?zqdm=%s";
  42. char szInfoStockstar[] = "http://quote.stockstar.com/stock/external_chart.asp?code=%s";
  43. char szInfoSohu[] = "http://stock.sohu.com/stock_image/fenshi.php?code=%s";
  44. char szInfoSinaSz[] = "http://stock.sina.com.cn/cgi-bin/stock/quote/minline.cgi?symbol=%s&country=sz";
  45. char szInfoSinaSh[] = "http://stock.sina.com.cn/cgi-bin/stock/quote/minline.cgi?symbol=%s&country=sh";
  46. char szInfo163[] = "http://stock2.163.com/stock/show_full.php?code=%s";
  47. char szInfoShse[] = "http://www.sse.com.cn/";
  48. char szInfoSzse[] = "http://www.szse.cn/";
  49. char szInfoHkex[] = "http://www.hkex.com.hk/";
  50. char szInfoLse[] = "http://www.londonstockexchange.com/";
  51. char szInfoNyse[] = "http://www.nyse.com/";
  52. char szInfoNasdaq[] = "http://www.nasdaq.com/";
  53. char szInfoP5w[] = "http://www.p5w.net/docs/stimes/today/";
  54. char szInfoSsnews[] = "http://www.ssnews.com.cn/shzqb/";
  55. char szInfoCs[] = "http://www.cs.com.cn/csnews/jrbz.htm";
  56. void CInfoView::ShowInfo( CStockInfo & info )
  57. {
  58. CString strURL;
  59. switch( m_nServer )
  60. {
  61. case serverSelf:
  62. {
  63. char szMarket[16];
  64. memset( szMarket, 0, sizeof(szMarket) );
  65. *((DWORD*)(szMarket)) = info.GetMarket();
  66. #ifdef CLKLAN_ENGLISH_US
  67. strURL.Format( szInfoSelf, (LPCTSTR)AfxGetProfile().GetHTTPServerDomain(), "enu", szMarket, info.GetStockCode() );
  68. #elif defined CLKVER_OEM
  69. strURL = CString("http://") + (LPCTSTR)AfxGetProfile().GetHTTPServerDomain();
  70. #else
  71. strURL.Format( szInfoSelf, (LPCTSTR)AfxGetProfile().GetHTTPServerDomain(), "chs", szMarket, info.GetStockCode() );
  72. #endif
  73. }
  74. break;
  75. case serverF10: strURL.Format( szInfoF10, info.GetStockCode() ); break;
  76. case serverStockstar: strURL.Format( szInfoStockstar, info.GetStockCode() ); break;
  77. case serverSohu: strURL.Format( szInfoSohu, info.GetStockCode() ); break;
  78. case serverSina: strURL.Format( info.IsShangHai() ? szInfoSinaSh : szInfoSinaSz, info.GetStockCode() ); break;
  79. case server163: strURL.Format( szInfo163, info.GetStockCode() ); break;
  80. case serverShse: strURL = szInfoShse; break;
  81. case serverSzse: strURL = szInfoSzse; break;
  82. case serverHkex: strURL = szInfoHkex; break;
  83. case serverLse: strURL = szInfoLse; break;
  84. case serverNyse: strURL = szInfoNyse; break;
  85. case serverNasdaq: strURL = szInfoNasdaq; break;
  86. case serverP5w: strURL = szInfoP5w; break;
  87. case serverSsnews: strURL = szInfoSsnews; break;
  88. case serverCs: strURL = szInfoCs; break;
  89. default:
  90. strURL.Format( szInfoStockstar, info.GetStockCode() );
  91. break;
  92. }
  93. Navigate( strURL );
  94. }
  95. BOOL CInfoView::IsViewF10( )
  96. {
  97. return ( serverF10 == GetCurrentServer() );
  98. }
  99. void CInfoView::DoDataExchange(CDataExchange* pDX)
  100. {
  101. CHtmlView::DoDataExchange(pDX);
  102. //{{AFX_DATA_MAP(CInfoView)
  103. // NOTE: the ClassWizard will add DDX and DDV calls here
  104. //}}AFX_DATA_MAP
  105. }
  106. void CInfoView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView) 
  107. {
  108. // TODO: Add your specialized code here and/or call the base class
  109. CHtmlView::OnActivateView(bActivate, pActivateView, pDeactiveView);
  110. if( bActivate )
  111. OnUpdate( NULL, UPDATE_HINT_INFOVIEW, NULL );
  112. }
  113. BEGIN_MESSAGE_MAP(CInfoView, CHtmlView)
  114. //{{AFX_MSG_MAP(CInfoView)
  115. ON_COMMAND(ID_VIEW_F10, OnViewF10)
  116. //}}AFX_MSG_MAP
  117. ON_MESSAGE(WM_USER_GETVIEWTITLE, OnGetViewTitle)
  118. ON_MESSAGE(WM_USER_GETVIEWCMDID, OnGetViewCmdid)
  119. END_MESSAGE_MAP()
  120. /////////////////////////////////////////////////////////////////////////////
  121. // CInfoView diagnostics
  122. #ifdef _DEBUG
  123. void CInfoView::AssertValid() const
  124. {
  125. CHtmlView::AssertValid();
  126. }
  127. void CInfoView::Dump(CDumpContext& dc) const
  128. {
  129. CHtmlView::Dump(dc);
  130. }
  131. #endif //_DEBUG
  132. /////////////////////////////////////////////////////////////////////////////
  133. // CInfoView message handlers
  134. void CInfoView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) 
  135. {
  136. // TODO: Add your specialized code here and/or call the base class
  137. if( UPDATE_HINT_INFOVIEW != lHint )
  138. return;
  139. if( IsWindowVisible() )
  140. SetFocus( );
  141. static int count = 0;
  142. count ++;
  143. if( count <= 2 && !IsWindowVisible() )
  144. return;
  145. CStockInfo info;
  146. if( AfxGetProfile().GetCurrentStock( &info ) )
  147. {
  148. }
  149. else if( AfxGetStockContainer().GetStockInfo( STKLIB_CODE_MAIN, &info ) )
  150. {
  151. AfxGetProfile().SetCurrentStock( STKLIB_CODE_MAIN, FALSE );
  152. }
  153. if( m_nServerShowed != m_nServer )
  154. {
  155. ShowInfo( info );
  156. m_infoCurrent = info;
  157. m_nServerShowed = m_nServer;
  158. return;
  159. }
  160. if( !m_infoCurrent.IsEqualTo(info.GetMarket(), info.GetStockCode()) )
  161. {
  162. if( serverSelf == m_nServer || serverF10 == m_nServer
  163. || serverStockstar == m_nServer || serverSohu == m_nServer
  164. || serverSina == m_nServer || server163 == m_nServer )
  165. {
  166. ShowInfo( info );
  167. m_infoCurrent = info;
  168. m_nServerShowed = m_nServer;
  169. return;
  170. }
  171. }
  172. }
  173. void CInfoView::OnViewF10() 
  174. {
  175. SetCurrentServer( serverF10 );
  176. OnRefresh();
  177. }
  178. LRESULT CInfoView::OnGetViewTitle(WPARAM wParam, LPARAM lParam)
  179. {
  180. CString strTitle;
  181. strTitle.LoadString( IDS_TITLE_INFOVIEW );
  182. lstrcpyn((LPTSTR)lParam, (LPCTSTR)strTitle, wParam);
  183. if ((int)wParam > strTitle.GetLength())
  184. wParam = strTitle.GetLength();
  185. return wParam;
  186. }
  187. LRESULT CInfoView::OnGetViewCmdid(WPARAM wParam, LPARAM lParam)
  188. {
  189. if( lParam )
  190. *((LPARAM *)lParam) = ID_VIEW_INFO;
  191. return 0L;
  192. }