MyStockView.cpp
上传用户:wenjimin
上传日期:2014-08-12
资源大小:111k
文件大小:18k
源码类别:

金融证券系统

开发平台:

Visual C++

  1. // MyStockView.cpp : implementation of the CMyStockView class
  2. //
  3. #include "stdafx.h"
  4. #include "MyStock.h"
  5. #include "MainFrm.h"
  6. //#include "MyStockDoc.h"
  7. #include "MyStockView.h"
  8. #include "GridCtrl.h"
  9. #include "STKDRV.h"
  10. CSTKDRV   gSTOCKDLL;//数据接口对象
  11. BOOL m_bFirstWindow=FALSE;//全局变量
  12. #ifdef _DEBUG
  13. #define new DEBUG_NEW
  14. #undef THIS_FILE
  15. static char THIS_FILE[] = __FILE__;
  16. #endif
  17. typedef struct tagMapData:public CObject
  18. {
  19. RCV_REPORT_STRUCTEx m_Report;
  20. }MapData,*pMapData;
  21. /////////////////////////////////////////////////////////////////////////////
  22. // CMyStockView
  23. IMPLEMENT_DYNCREATE(CMyStockView, CView)
  24. BEGIN_MESSAGE_MAP(CMyStockView, CView)
  25. //{{AFX_MSG_MAP(CMyStockView)
  26. ON_WM_CREATE()
  27. ON_WM_SHOWWINDOW()
  28. ON_WM_DESTROY()
  29. ON_WM_SIZE()
  30. ON_COMMAND(ID_STOCK, OnStock)
  31. ON_UPDATE_COMMAND_UI(ID_STOCK, OnUpdateStock)
  32. ON_COMMAND(ID_UNSTOCK, OnUnstock)
  33. ON_UPDATE_COMMAND_UI(ID_UNSTOCK, OnUpdateUnstock)
  34. //}}AFX_MSG_MAP
  35. // Standard printing commands
  36. ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
  37. ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
  38. ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
  39. ON_MESSAGE(My_Msg_StkData,OnStkDataOK)
  40. END_MESSAGE_MAP()
  41. /////////////////////////////////////////////////////////////////////////////
  42. // CMyStockView construction/destruction
  43. CMyStockView::CMyStockView()
  44. {
  45. m_bStocker=FALSE;
  46.     m_nToal=0;
  47. m_FillCell=FALSE;
  48. m_bSHnumber=FALSE;
  49. m_bUpdataAllView=FALSE;
  50. m_wMarket=SH_MARKET_EX;
  51. m_sType="6";
  52. if(m_fSHFile.Open(".\SHnumber.txt",CFile::modeReadWrite))
  53. m_bSHnumber=true;
  54. }
  55. CMyStockView::~CMyStockView()
  56. {
  57. }
  58. BOOL CMyStockView::PreCreateWindow(CREATESTRUCT& cs)
  59. {
  60. // TODO: Modify the Window class or styles here by modifying
  61. //  the CREATESTRUCT cs
  62. return CView::PreCreateWindow(cs);
  63. }
  64. /////////////////////////////////////////////////////////////////////////////
  65. // CMyStockView drawing
  66. void CMyStockView::OnDraw(CDC* pDC)
  67. {
  68. CMyStockDoc* pDoc = GetDocument();
  69. ASSERT_VALID(pDoc);
  70. if(!m_FillCell)
  71. SetGridData();
  72. if(m_bFirstWindow)
  73. pDC->TextOut(100,100,"蒋小利");
  74. }
  75. /////////////////////////////////////////////////////////////////////////////
  76. // CMyStockView printing
  77. BOOL CMyStockView::OnPreparePrinting(CPrintInfo* pInfo)
  78. {
  79. // default preparation
  80. return DoPreparePrinting(pInfo);
  81. }
  82. void CMyStockView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
  83. {
  84. // TODO: add extra initialization before printing
  85. }
  86. void CMyStockView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
  87. {
  88. // TODO: add cleanup after printing
  89. }
  90. /////////////////////////////////////////////////////////////////////////////
  91. // CMyStockView diagnostics
  92. #ifdef _DEBUG
  93. void CMyStockView::AssertValid() const
  94. {
  95. CView::AssertValid();
  96. }
  97. void CMyStockView::Dump(CDumpContext& dc) const
  98. {
  99. CView::Dump(dc);
  100. }
  101. CMyStockDoc* CMyStockView::GetDocument() // non-debug version is inline
  102. {
  103. ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMyStockDoc)));
  104. return (CMyStockDoc*)m_pDocument;
  105. }
  106. #endif //_DEBUG
  107. /////////////////////////////////////////////////////////////////////////////
  108. // CMyStockView message handlers
  109. int CMyStockView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
  110. {
  111. if (CView::OnCreate(lpCreateStruct) == -1)
  112. return -1;
  113. //创建动态显示牌表格:
  114. pGridFrame=new CMyGridFrame;
  115. pGridFrame->Create(NULL,NULL,WS_CHILD|WS_VISIBLE,CRect(0,0,800,600),this,ID_GRIDCTRL1);
  116. // pGridFrame->m_grid.SetFixedRowCount(1);//固定行(列标头)
  117. // pGridFrame->m_grid.SetFixedColumnCount(3);//固定列(行标头)
  118. // pGridFrame->m_grid.SetRowCount(501);//总行数
  119. // pGridFrame->m_grid.SetColumnCount(15);//总列数
  120. // pGridFrame->m_grid.SetColumnWidth(0,40);//指定列宽
  121. // pGridFrame->m_grid.SetHeaderSort(true);//允许排序
  122. // pGridFrame->m_grid.SetGridBkColor(RGB(255,255,255));
  123. //以下这些参数都可以用变量代替,以便和用户交互
  124. // pGridFrame->m_grid.SetFixedBkColor(RGB(255,255,255));
  125. // pGridFrame->m_grid.SetFixedTextColor(RGB(0,0,0));
  126. // pGridFrame->m_grid.SetItemText(0,1,"代  码");
  127. //    pGridFrame->m_grid.SetItemText(0,2,"名  称");
  128. //    pGridFrame->m_grid.SetItemText(0,3,"最新价");
  129. //   pGridFrame->m_grid.SetItemText(0,4,"涨  跌");
  130. //    pGridFrame->m_grid.SetItemText(0,5,"涨跌幅");
  131. //    pGridFrame->m_grid.SetItemText(0,6,"总  手");
  132. //    pGridFrame->m_grid.SetItemText(0,7,"最高价");
  133. //    pGridFrame->m_grid.SetItemText(0,8,"最低价");
  134. //    pGridFrame->m_grid.SetItemText(0,9,"今开盘");
  135. //    pGridFrame->m_grid.SetItemText(0,10,"昨收盘");
  136. //    pGridFrame->m_grid.SetItemText(0,11,"总  额");
  137. return 0;
  138. }
  139. void CMyStockView::OnShowWindow(BOOL bShow, UINT nStatus) 
  140. {
  141. CView::OnShowWindow(bShow, nStatus);
  142.  /*  if(!m_bStocker)
  143.    {
  144.    gSTOCKDLL.GetStockDrvInfo(RI_SUPPORTEXTHQ,NULL); //设置 Szn Label6 Receive
  145.    int ok = gSTOCKDLL.Stock_Init(m_hWnd,My_Msg_StkData,RCV_WORK_SENDMSG); // 数据共享引用
  146.    if( ok > 0 )
  147.    {
  148.    //
  149.      DWORD m_TV_Code = 201;
  150.      gSTOCKDLL.GetStockDrvInfo(RI_ENABLETS3FILE,&m_TV_Code);
  151.     m_bStocker=true;
  152.    }
  153.    }*/
  154. }
  155. void CMyStockView::OnDestroy() 
  156. {
  157. CView::OnDestroy();
  158. gSTOCKDLL.Stock_Quit(m_hWnd);
  159. m_bStocker=FALSE;     //窗口都已经销毁,无所谓了。
  160. }
  161. //接口响应函数
  162. LONG CMyStockView::OnStkDataOK(UINT wFileType,LONG lPara)
  163. {
  164. //MessageBox("Data OK!!!");//你可以用它检验接口
  165. CMyStockDoc* pDoc=GetDocument();
  166. int i;
  167. PBYTE pFileBuf = NULL;
  168. RCV_DATA * pHeader;
  169. pHeader = (RCV_DATA *) lPara;
  170. CString string;
  171. switch( wFileType )
  172. {
  173. case RCV_REPORT:
  174. {
  175. int nBufSize = pHeader->m_pReport[0].m_cbSize;
  176. PBYTE pBaseBuf = (PBYTE)&pHeader->m_pReport[0];
  177. for(i=0; i<pHeader->m_nPacketNum; i++)
  178. {
  179. pMapData  m_mapdata=new MapData;
  180. ASSERT(m_mapdata);
  181. RCV_REPORT_STRUCTEx & Buf = *(PRCV_REPORT_STRUCTEx)(pBaseBuf + nBufSize*i );
  182. if(Buf.m_wMarket==m_wMarket)//SH_MARKET_EX )//上海市场
  183. {
  184. string=Buf.m_szLabel;
  185. CString cc=string.Left(1);
  186. if(!strcmp(cc,m_sType))//上海A股
  187. {
  188. if(!m_FillCell)
  189. {
  190. m_mapdata->m_Report.m_cbSize=Buf.m_cbSize;
  191.     m_mapdata->m_Report.m_fAmount=Buf.m_fAmount;
  192.     m_mapdata->m_Report.m_fBuyPrice[1]=Buf.m_fBuyPrice[1];
  193.     m_mapdata->m_Report.m_fBuyPrice[2]=Buf.m_fBuyPrice[2];
  194.     m_mapdata->m_Report.m_fBuyPrice[3]=Buf.m_fBuyPrice[3];
  195.     m_mapdata->m_Report.m_fBuyPrice4=Buf.m_fBuyPrice4;
  196.    // m_mapdata->m_Report.m_fBuyPrice5=Buf.m_fBuyPrice5;
  197.     m_mapdata->m_Report.m_fBuyVolume[1]=Buf.m_fBuyVolume[1];
  198.     m_mapdata->m_Report.m_fBuyVolume[2]=Buf.m_fBuyVolume[2];
  199.     m_mapdata->m_Report.m_fBuyVolume[3]=Buf.m_fBuyVolume[3];
  200.     m_mapdata->m_Report.m_fBuyVolume4=Buf.m_fBuyVolume4;
  201.    // m_mapdata->m_Report.m_fBuyVolume5=Buf.m_fBuyVolume5;
  202.     m_mapdata->m_Report.m_fHigh=Buf.m_fHigh;
  203.     m_mapdata->m_Report.m_fLastClose=Buf.m_fLastClose;
  204.     m_mapdata->m_Report.m_fLow=Buf.m_fLow;
  205.     m_mapdata->m_Report.m_fNewPrice=Buf.m_fNewPrice;
  206.     m_mapdata->m_Report.m_fOpen=Buf.m_fOpen;
  207.     m_mapdata->m_Report.m_fSellPrice[1]=Buf.m_fSellPrice[1];
  208.     m_mapdata->m_Report.m_fSellPrice[2]=Buf.m_fSellPrice[2];
  209.     m_mapdata->m_Report.m_fSellPrice[3]=Buf.m_fSellPrice[3];
  210.     m_mapdata->m_Report.m_fSellPrice4=Buf.m_fSellPrice4;
  211.   //  m_mapdata->m_Report.m_fSellPrice5=Buf.m_fSellPrice5;
  212.     m_mapdata->m_Report.m_fSellVolume[1]=Buf.m_fSellVolume[1];
  213.     m_mapdata->m_Report.m_fSellVolume[2]=Buf.m_fSellVolume[2];
  214.     m_mapdata->m_Report.m_fSellVolume[3]=Buf.m_fSellVolume[3];
  215.     m_mapdata->m_Report.m_fSellVolume4=Buf.m_fSellVolume4;
  216.   //  m_mapdata->m_Report.m_fSellVolume5=Buf.m_fSellVolume5;
  217.     m_mapdata->m_Report.m_fVolume=Buf.m_fVolume;
  218.     strcpy(m_mapdata->m_Report.m_szLabel,Buf.m_szLabel);
  219.     strcpy(m_mapdata->m_Report.m_szName,Buf.m_szName);
  220.     m_mapdata->m_Report.m_time=Buf.m_time;
  221.     m_mapdata->m_Report.m_wMarket=Buf.m_wMarket;
  222.     pDoc->m_DataMap.SetAt(string,m_mapdata);
  223. // pDoc->m_FileName="600198";//测试用
  224. SetGridData();
  225. if(m_nToal==pDoc->m_DataMap.GetCount())
  226. m_FillCell=true;
  227. m_nToal=pDoc->m_DataMap.GetCount();
  228. }
  229. if(m_FillCell)
  230. {
  231. for(int p=1;p<pGridFrame->m_grid.GetRowCount();p++)
  232. {
  233. CGridCellBase* pCell=pGridFrame->m_grid.GetCell(p,1);
  234. CString mystr=pCell->GetText();
  235. if(!mystr.IsEmpty())//如果不是空的
  236. {
  237.   string.Format("%6s",Buf.m_szLabel);//代码
  238.   if(!strcmp(mystr,string))//如果相等
  239.   {
  240.     pGridFrame->m_grid.SetItemText(p,1,string);
  241. string.Format("%8s",Buf.m_szName);//名称
  242. pGridFrame->m_grid.SetItemText(p,2,string);
  243. string.Format("%8.2f",Buf.m_fNewPrice);//最新
  244. pGridFrame->m_grid.SetItemText(p,3,string);
  245. string.Format("%8.2f",Buf.m_fNewPrice-Buf.m_fLastClose);//涨跌
  246. pGridFrame->m_grid.SetItemText(p,4,string);
  247. if(Buf.m_fNewPrice-Buf.m_fLastClose>0)
  248. {
  249.    pGridFrame->m_grid.SetItemFgColor(p,4,RGB(255,0,0));
  250.    pGridFrame->m_grid.SetItemFgColor(p,3,RGB(255,0,0));
  251.    pGridFrame->m_grid.SetItemFgColor(p,5,RGB(255,0,0));
  252.    pGridFrame->m_grid.SetItemFgColor(p,7,RGB(255,0,0));
  253. }
  254. if(Buf.m_fNewPrice-Buf.m_fLastClose<0)
  255. {
  256. pGridFrame->m_grid.SetItemFgColor(p,4,RGB(10,160,36));
  257. pGridFrame->m_grid.SetItemFgColor(p,3,RGB(10,160,36));
  258. pGridFrame->m_grid.SetItemFgColor(p,5,RGB(10,160,36));
  259. pGridFrame->m_grid.SetItemFgColor(p,7,RGB(10,160,36));
  260. }
  261. if(Buf.m_fNewPrice-Buf.m_fLastClose==0.00)
  262. {
  263. string.Format("%8.2f",0.00);
  264. }
  265. else
  266. {
  267. string.Format("%8.2f",(Buf.m_fNewPrice-Buf.m_fLastClose)/Buf.m_fLastClose*100);
  268. }
  269. string+="%";
  270. pGridFrame->m_grid.SetItemText(p,5,string);//涨跌幅
  271. string.Format("%10.0f",Buf.m_fVolume);//总手
  272. pGridFrame->m_grid.SetItemText(p,6,string);
  273. string.Format("%8.2f",Buf.m_fHigh);//最高
  274. if(Buf.m_fHigh>Buf.m_fLastClose)
  275. pGridFrame->m_grid.SetItemFgColor(p,7,RGB(255,0,0));
  276. if(Buf.m_fHigh<Buf.m_fLastClose)
  277. pGridFrame->m_grid.SetItemFgColor(p,7,RGB(10,160,36));
  278. pGridFrame->m_grid.SetItemText(p,7,string);
  279. string.Format("%8.2f",Buf.m_fLow);//最低
  280. if(Buf.m_fLow>Buf.m_fLastClose)
  281. pGridFrame->m_grid.SetItemFgColor(p,8,RGB(255,0,0));
  282. if(Buf.m_fLow<Buf.m_fLastClose)
  283. pGridFrame->m_grid.SetItemFgColor(p,8,RGB(10,160,36));
  284. pGridFrame->m_grid.SetItemText(p,8,string);
  285. string.Format("%8.2f",Buf.m_fOpen);//今开
  286. if(Buf.m_fOpen>Buf.m_fLastClose)
  287. pGridFrame->m_grid.SetItemFgColor(p,9,RGB(255,0,0));
  288. if(Buf.m_fOpen<Buf.m_fLastClose)
  289. pGridFrame->m_grid.SetItemFgColor(p,9,RGB(10,160,36));
  290. pGridFrame->m_grid.SetItemText(p,9,string);
  291. string.Format("%8.2f",Buf.m_fLastClose);//昨收
  292. pGridFrame->m_grid.SetItemText(p,10,string);
  293. string.Format("%10.0f",Buf.m_fAmount);//总额
  294. pGridFrame->m_grid.SetItemText(p,11,string);
  295. pGridFrame->m_grid.RedrawRow(p);
  296. //pDoc->m_FileName="600839";//测试用
  297. if(!(strcmp(string,pDoc->m_FileName)))
  298. m_bUpdataAllView=true;
  299. break;
  300.   }
  301. }
  302. }
  303. }
  304. }
  305. if(m_bUpdataAllView)
  306. {
  307. pDoc->UpdateAllViews(this);
  308. m_bUpdataAllView=FALSE;
  309. }
  310. }
  311. }
  312. }
  313. break;
  314. case RCV_FILEDATA:
  315.     if( !pHeader->m_pData || pHeader->m_wDataType == FILE_TYPE_RES)
  316. {
  317. TRACE("MSG: CStkDemo::OnStkDataOK, Replaced data n");
  318. break;
  319. }
  320. switch(pHeader->m_wDataType)
  321. {
  322. case FILE_HISTORY_EX: // 补日线数据
  323. break;
  324. case FILE_MINUTE_EX: // 补分钟线数据
  325. break;
  326. case FILE_BASE_EX: // 钱龙兼容基本资料文件,m_szFileName仅包含文件名
  327. break;
  328. case FILE_NEWS_EX: // 新闻类,其类型由m_szFileName中子目录名来定
  329. break;
  330. case FILE_SOFTWARE_EX:
  331. break;
  332. case FILE_SHAZQDATA_EX: //h上海国债净价交易
  333. break;
  334. default:
  335. TRACE("Msg: CStkDemo::OnStkDataOK,Unkonw data typen");
  336. }
  337. break;
  338. }
  339. //RedrawWindow();
  340. return 0L;
  341. }
  342. void CMyStockView::OnSize(UINT nType, int cx, int cy) 
  343. {
  344. CView::OnSize(nType, cx, cy);
  345. pGridFrame->SetWindowPos(NULL,0,0,cx,cy,SWP_SHOWWINDOW);//调整表格
  346. //失能窗口的关闭按钮:
  347. CWnd* pParen=this->GetParent();
  348. CMenu* pmenu=pParen->GetSystemMenu(FALSE);
  349. if(! m_bFirstWindow)
  350. {
  351. if(pmenu)
  352. {
  353. pmenu->DeleteMenu(SC_CLOSE,MF_BYCOMMAND);
  354. }
  355. m_bFirstWindow=true;
  356. }
  357. }
  358. void CMyStockView::OnStock() 
  359. {
  360.  if(!m_bStocker)
  361.    {
  362.    gSTOCKDLL.GetStockDrvInfo(RI_SUPPORTEXTHQ,NULL); //设置 Szn Label6 Receive
  363.    int ok = gSTOCKDLL.Stock_Init(m_hWnd,My_Msg_StkData,RCV_WORK_SENDMSG); // 数据共享引用
  364.    if( ok > 0 )
  365.    {
  366.    //
  367.      DWORD m_TV_Code = 201;
  368.      gSTOCKDLL.GetStockDrvInfo(RI_ENABLETS3FILE,&m_TV_Code);
  369.     m_bStocker=true;
  370.    }
  371.    }
  372. }
  373. void CMyStockView::OnUpdateStock(CCmdUI* pCmdUI) 
  374. {
  375. if(m_bStocker)
  376. {
  377. pCmdUI->Enable(FALSE);
  378. }
  379. else
  380. {
  381. pCmdUI->Enable(true);
  382. }
  383. }
  384. int CMyStockView::SetGridData()
  385. {
  386. CMyStockDoc* pDoc = GetDocument();
  387. ASSERT_VALID(pDoc);
  388. POSITION pos=pDoc->m_DataMap.GetStartPosition();
  389. int lines=pDoc->m_DataMap.GetCount();
  390. if(lines>100)
  391. pGridFrame->m_grid.SetRowCount(lines+1);
  392. CString string,string1;
  393. pMapData m_pMapdata=new MapData;
  394. int row=1;
  395. while(pos !=NULL)
  396. {
  397. pDoc->m_DataMap.GetNextAssoc(pos,string1,(CObject *&)m_pMapdata);
  398. string.Format("%6s",m_pMapdata->m_Report.m_szLabel);//代码
  399.  pGridFrame->m_grid.SetItemText(row,1,string);
  400.          string.Format("%8s",m_pMapdata->m_Report.m_szName);//名称
  401.          string1=string;
  402.          pGridFrame->m_grid.SetItemText(row,2,string);
  403.  
  404.          string.Format("%8.2f",m_pMapdata->m_Report.m_fNewPrice);//最新
  405.          pGridFrame->m_grid.SetItemText(row,3,string);
  406.          string.Format("%8.2f",m_pMapdata->m_Report.m_fNewPrice-m_pMapdata->m_Report.m_fLastClose);//涨跌
  407.          pGridFrame->m_grid.SetItemText(row,4,string);
  408.          if(m_pMapdata->m_Report.m_fNewPrice-m_pMapdata->m_Report.m_fLastClose>0)
  409.  {
  410.        pGridFrame->m_grid.SetItemFgColor(row,4,RGB(255,0,0));
  411.        pGridFrame->m_grid.SetItemFgColor(row,3,RGB(255,0,0));
  412.        pGridFrame->m_grid.SetItemFgColor(row,5,RGB(255,0,0));
  413.        pGridFrame->m_grid.SetItemFgColor(row,7,RGB(255,0,0));
  414.  }
  415.          if(m_pMapdata->m_Report.m_fNewPrice-m_pMapdata->m_Report.m_fLastClose<0)
  416.  {
  417.      pGridFrame->m_grid.SetItemFgColor(row,4,RGB(10,160,36));
  418.      pGridFrame->m_grid.SetItemFgColor(row,3,RGB(10,160,36));
  419.      pGridFrame->m_grid.SetItemFgColor(row,5,RGB(10,160,36));
  420.  pGridFrame->m_grid.SetItemFgColor(row,7,RGB(10,160,36));
  421.  }
  422.                 if(m_pMapdata->m_Report.m_fNewPrice-m_pMapdata->m_Report.m_fLastClose==0.00)
  423. {
  424.        string.Format("%8.2f",0.00);
  425. }
  426.        else
  427.    {
  428.        string.Format("%8.2f",(m_pMapdata->m_Report.m_fNewPrice-m_pMapdata->m_Report.m_fLastClose)/m_pMapdata->m_Report.m_fLastClose*100);
  429.    }
  430.        string+="%";
  431.        pGridFrame->m_grid.SetItemText(row,5,string);//涨跌幅
  432.        string.Format("%10.0f",m_pMapdata->m_Report.m_fVolume);//总手
  433.        pGridFrame->m_grid.SetItemText(row,6,string);
  434.        string.Format("%8.2f",m_pMapdata->m_Report.m_fHigh);//最高
  435.        if(m_pMapdata->m_Report.m_fHigh>m_pMapdata->m_Report.m_fLastClose)
  436.      pGridFrame->m_grid.SetItemFgColor(row,7,RGB(255,0,0));
  437.        if(m_pMapdata->m_Report.m_fHigh<m_pMapdata->m_Report.m_fLastClose)
  438.      pGridFrame->m_grid.SetItemFgColor(row,7,RGB(10,160,36));
  439.            pGridFrame->m_grid.SetItemText(row,7,string);
  440.       string.Format("%8.2f",m_pMapdata->m_Report.m_fLow);//最低
  441.           if(m_pMapdata->m_Report.m_fLow>m_pMapdata->m_Report.m_fLastClose)
  442.      pGridFrame->m_grid.SetItemFgColor(row,8,RGB(255,0,0));
  443.       if(m_pMapdata->m_Report.m_fLow<m_pMapdata->m_Report.m_fLastClose)
  444.      pGridFrame->m_grid.SetItemFgColor(row,8,RGB(10,160,36));
  445.          pGridFrame->m_grid.SetItemText(row,8,string);
  446.      string.Format("%8.2f",m_pMapdata->m_Report.m_fOpen);//今开
  447.      if(m_pMapdata->m_Report.m_fOpen>m_pMapdata->m_Report.m_fLastClose)
  448.    pGridFrame->m_grid.SetItemFgColor(row,9,RGB(255,0,0));
  449.      if(m_pMapdata->m_Report.m_fOpen<m_pMapdata->m_Report.m_fLastClose)
  450.    pGridFrame->m_grid.SetItemFgColor(row,9,RGB(10,160,36));
  451.      pGridFrame->m_grid.SetItemText(row,9,string);
  452.      string.Format("%8.2f",m_pMapdata->m_Report.m_fLastClose);//昨收
  453.              pGridFrame->m_grid.SetItemText(row,10,string);
  454.      string.Format("%10.0f",m_pMapdata->m_Report.m_fAmount);//总额
  455.      pGridFrame->m_grid.SetItemText(row,11,string);
  456.  
  457.  row++;
  458. }
  459. pGridFrame->m_grid.Refresh();
  460. return 0;
  461. }
  462. void CMyStockView::OnUnstock() 
  463. {
  464. gSTOCKDLL.Stock_Quit(m_hWnd);
  465. m_bStocker=FALSE;    
  466. }
  467. void CMyStockView::OnUpdateUnstock(CCmdUI* pCmdUI) 
  468. {
  469. if(!m_bStocker)
  470. {
  471. pCmdUI->Enable(FALSE);
  472. }
  473. else
  474. {
  475. pCmdUI->Enable(true);
  476. }
  477. }
  478. int CMyStockView::ONNewFile(CString string)
  479. {
  480. CMyStockDoc* pDoc=GetDocument();
  481. pDoc->m_FileName=string;
  482. CMainFrame* pFrame=(CMainFrame*)AfxGetMainWnd();
  483. pFrame->OnNewview();
  484. return 0;
  485. }