?? mystockview.cpp
字號:
pGridFrame->m_grid.SetItemText(p,1,string);
string.Format("%8s",Buf.m_szName);//名稱
pGridFrame->m_grid.SetItemText(p,2,string);
string.Format("%8.2f",Buf.m_fNewPrice);//最新
pGridFrame->m_grid.SetItemText(p,3,string);
string.Format("%8.2f",Buf.m_fNewPrice-Buf.m_fLastClose);//漲跌
pGridFrame->m_grid.SetItemText(p,4,string);
if(Buf.m_fNewPrice-Buf.m_fLastClose>0)
{
pGridFrame->m_grid.SetItemFgColor(p,4,RGB(255,0,0));
pGridFrame->m_grid.SetItemFgColor(p,3,RGB(255,0,0));
pGridFrame->m_grid.SetItemFgColor(p,5,RGB(255,0,0));
pGridFrame->m_grid.SetItemFgColor(p,7,RGB(255,0,0));
}
if(Buf.m_fNewPrice-Buf.m_fLastClose<0)
{
pGridFrame->m_grid.SetItemFgColor(p,4,RGB(10,160,36));
pGridFrame->m_grid.SetItemFgColor(p,3,RGB(10,160,36));
pGridFrame->m_grid.SetItemFgColor(p,5,RGB(10,160,36));
pGridFrame->m_grid.SetItemFgColor(p,7,RGB(10,160,36));
}
if(Buf.m_fNewPrice-Buf.m_fLastClose==0.00)
{
string.Format("%8.2f",0.00);
}
else
{
string.Format("%8.2f",(Buf.m_fNewPrice-Buf.m_fLastClose)/Buf.m_fLastClose*100);
}
string+="%";
pGridFrame->m_grid.SetItemText(p,5,string);//漲跌幅
string.Format("%10.0f",Buf.m_fVolume);//總手
pGridFrame->m_grid.SetItemText(p,6,string);
string.Format("%8.2f",Buf.m_fHigh);//最高
if(Buf.m_fHigh>Buf.m_fLastClose)
pGridFrame->m_grid.SetItemFgColor(p,7,RGB(255,0,0));
if(Buf.m_fHigh<Buf.m_fLastClose)
pGridFrame->m_grid.SetItemFgColor(p,7,RGB(10,160,36));
pGridFrame->m_grid.SetItemText(p,7,string);
string.Format("%8.2f",Buf.m_fLow);//最低
if(Buf.m_fLow>Buf.m_fLastClose)
pGridFrame->m_grid.SetItemFgColor(p,8,RGB(255,0,0));
if(Buf.m_fLow<Buf.m_fLastClose)
pGridFrame->m_grid.SetItemFgColor(p,8,RGB(10,160,36));
pGridFrame->m_grid.SetItemText(p,8,string);
string.Format("%8.2f",Buf.m_fOpen);//今開
if(Buf.m_fOpen>Buf.m_fLastClose)
pGridFrame->m_grid.SetItemFgColor(p,9,RGB(255,0,0));
if(Buf.m_fOpen<Buf.m_fLastClose)
pGridFrame->m_grid.SetItemFgColor(p,9,RGB(10,160,36));
pGridFrame->m_grid.SetItemText(p,9,string);
string.Format("%8.2f",Buf.m_fLastClose);//昨收
pGridFrame->m_grid.SetItemText(p,10,string);
string.Format("%10.0f",Buf.m_fAmount);//總額
pGridFrame->m_grid.SetItemText(p,11,string);
pGridFrame->m_grid.RedrawRow(p);
//pDoc->m_FileName="600839";//測試用
if(!(strcmp(string,pDoc->m_FileName)))
m_bUpdataAllView=true;
break;
}
}
}
}
}
if(m_bUpdataAllView)
{
pDoc->UpdateAllViews(this);
m_bUpdataAllView=FALSE;
}
}
}
}
break;
case RCV_FILEDATA:
if( !pHeader->m_pData || pHeader->m_wDataType == FILE_TYPE_RES)
{
TRACE("MSG: CStkDemo::OnStkDataOK, Replaced data \n");
break;
}
switch(pHeader->m_wDataType)
{
case FILE_HISTORY_EX: // 補日線數(shù)據(jù)
break;
case FILE_MINUTE_EX: // 補分鐘線數(shù)據(jù)
break;
case FILE_BASE_EX: // 錢龍兼容基本資料文件,m_szFileName僅包含文件名
break;
case FILE_NEWS_EX: // 新聞類,其類型由m_szFileName中子目錄名來定
break;
case FILE_SOFTWARE_EX:
break;
case FILE_SHAZQDATA_EX: //h上海國債凈價交易
break;
default:
TRACE("Msg: CStkDemo::OnStkDataOK,Unkonw data type\n");
}
break;
}
//RedrawWindow();
return 0L;
}
void CMyStockView::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);
pGridFrame->SetWindowPos(NULL,0,0,cx,cy,SWP_SHOWWINDOW);//調(diào)整表格
//失能窗口的關(guān)閉按鈕:
CWnd* pParen=this->GetParent();
CMenu* pmenu=pParen->GetSystemMenu(FALSE);
if(! m_bFirstWindow)
{
if(pmenu)
{
pmenu->DeleteMenu(SC_CLOSE,MF_BYCOMMAND);
}
m_bFirstWindow=true;
}
}
void CMyStockView::OnStock()
{
if(!m_bStocker)
{
gSTOCKDLL.GetStockDrvInfo(RI_SUPPORTEXTHQ,NULL); //設(shè)置 Szn Label6 Receive
int ok = gSTOCKDLL.Stock_Init(m_hWnd,My_Msg_StkData,RCV_WORK_SENDMSG); // 數(shù)據(jù)共享引用
if( ok > 0 )
{
//
DWORD m_TV_Code = 201;
gSTOCKDLL.GetStockDrvInfo(RI_ENABLETS3FILE,&m_TV_Code);
m_bStocker=true;
}
}
}
void CMyStockView::OnUpdateStock(CCmdUI* pCmdUI)
{
if(m_bStocker)
{
pCmdUI->Enable(FALSE);
}
else
{
pCmdUI->Enable(true);
}
}
int CMyStockView::SetGridData()
{
CMyStockDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
POSITION pos=pDoc->m_DataMap.GetStartPosition();
int lines=pDoc->m_DataMap.GetCount();
if(lines>100)
pGridFrame->m_grid.SetRowCount(lines+1);
CString string,string1;
pMapData m_pMapdata=new MapData;
int row=1;
while(pos !=NULL)
{
pDoc->m_DataMap.GetNextAssoc(pos,string1,(CObject *&)m_pMapdata);
string.Format("%6s",m_pMapdata->m_Report.m_szLabel);//代碼
pGridFrame->m_grid.SetItemText(row,1,string);
string.Format("%8s",m_pMapdata->m_Report.m_szName);//名稱
string1=string;
pGridFrame->m_grid.SetItemText(row,2,string);
string.Format("%8.2f",m_pMapdata->m_Report.m_fNewPrice);//最新
pGridFrame->m_grid.SetItemText(row,3,string);
string.Format("%8.2f",m_pMapdata->m_Report.m_fNewPrice-m_pMapdata->m_Report.m_fLastClose);//漲跌
pGridFrame->m_grid.SetItemText(row,4,string);
if(m_pMapdata->m_Report.m_fNewPrice-m_pMapdata->m_Report.m_fLastClose>0)
{
pGridFrame->m_grid.SetItemFgColor(row,4,RGB(255,0,0));
pGridFrame->m_grid.SetItemFgColor(row,3,RGB(255,0,0));
pGridFrame->m_grid.SetItemFgColor(row,5,RGB(255,0,0));
pGridFrame->m_grid.SetItemFgColor(row,7,RGB(255,0,0));
}
if(m_pMapdata->m_Report.m_fNewPrice-m_pMapdata->m_Report.m_fLastClose<0)
{
pGridFrame->m_grid.SetItemFgColor(row,4,RGB(10,160,36));
pGridFrame->m_grid.SetItemFgColor(row,3,RGB(10,160,36));
pGridFrame->m_grid.SetItemFgColor(row,5,RGB(10,160,36));
pGridFrame->m_grid.SetItemFgColor(row,7,RGB(10,160,36));
}
if(m_pMapdata->m_Report.m_fNewPrice-m_pMapdata->m_Report.m_fLastClose==0.00)
{
string.Format("%8.2f",0.00);
}
else
{
string.Format("%8.2f",(m_pMapdata->m_Report.m_fNewPrice-m_pMapdata->m_Report.m_fLastClose)/m_pMapdata->m_Report.m_fLastClose*100);
}
string+="%";
pGridFrame->m_grid.SetItemText(row,5,string);//漲跌幅
string.Format("%10.0f",m_pMapdata->m_Report.m_fVolume);//總手
pGridFrame->m_grid.SetItemText(row,6,string);
string.Format("%8.2f",m_pMapdata->m_Report.m_fHigh);//最高
if(m_pMapdata->m_Report.m_fHigh>m_pMapdata->m_Report.m_fLastClose)
pGridFrame->m_grid.SetItemFgColor(row,7,RGB(255,0,0));
if(m_pMapdata->m_Report.m_fHigh<m_pMapdata->m_Report.m_fLastClose)
pGridFrame->m_grid.SetItemFgColor(row,7,RGB(10,160,36));
pGridFrame->m_grid.SetItemText(row,7,string);
string.Format("%8.2f",m_pMapdata->m_Report.m_fLow);//最低
if(m_pMapdata->m_Report.m_fLow>m_pMapdata->m_Report.m_fLastClose)
pGridFrame->m_grid.SetItemFgColor(row,8,RGB(255,0,0));
if(m_pMapdata->m_Report.m_fLow<m_pMapdata->m_Report.m_fLastClose)
pGridFrame->m_grid.SetItemFgColor(row,8,RGB(10,160,36));
pGridFrame->m_grid.SetItemText(row,8,string);
string.Format("%8.2f",m_pMapdata->m_Report.m_fOpen);//今開
if(m_pMapdata->m_Report.m_fOpen>m_pMapdata->m_Report.m_fLastClose)
pGridFrame->m_grid.SetItemFgColor(row,9,RGB(255,0,0));
if(m_pMapdata->m_Report.m_fOpen<m_pMapdata->m_Report.m_fLastClose)
pGridFrame->m_grid.SetItemFgColor(row,9,RGB(10,160,36));
pGridFrame->m_grid.SetItemText(row,9,string);
string.Format("%8.2f",m_pMapdata->m_Report.m_fLastClose);//昨收
pGridFrame->m_grid.SetItemText(row,10,string);
string.Format("%10.0f",m_pMapdata->m_Report.m_fAmount);//總額
pGridFrame->m_grid.SetItemText(row,11,string);
row++;
}
pGridFrame->m_grid.Refresh();
return 0;
}
void CMyStockView::OnUnstock()
{
gSTOCKDLL.Stock_Quit(m_hWnd);
m_bStocker=FALSE;
}
void CMyStockView::OnUpdateUnstock(CCmdUI* pCmdUI)
{
if(!m_bStocker)
{
pCmdUI->Enable(FALSE);
}
else
{
pCmdUI->Enable(true);
}
}
int CMyStockView::ONNewFile(CString string)
{
CMyStockDoc* pDoc=GetDocument();
pDoc->m_FileName=string;
CMainFrame* pFrame=(CMainFrame*)AfxGetMainWnd();
pFrame->OnNewview();
return 0;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -