KlineLeftView.h
#pragma once
#include "afxwin.h"
class CKlineLeftView : public CFormView
{
DECLARE_DYNCREATE(CKlineLeftView)
protected:
CKlineLeftView();
virtual ~CKlineLeftView();
public:
enum {
IDD = IDD_FORMVIEW_LEFT };
#ifdef _DEBUG
virtual void AssertValid() const;
#ifndef _WIN32_WCE
virtual void Dump(CDumpContext& dc) const;
#endif
#endif
protected:
virtual void DoDataExchange(CDataExchange* pDX);
DECLARE_MESSAGE_MAP()
public:
virtual void OnInitialUpdate();
protected:
virtual void OnDraw(CDC* );
public:
afx_msg void OnStnClickedKonemin();
afx_msg void OnSize(UINT nType, int cx, int cy);
void Updata(int IDP);
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
void RePaint(void);
CDC* pDC;
afx_msg void OnTimer(UINT_PTR nIDEvent);
CRect rect;
};
#pragma once
KlineLeftView.cpp
#include "stdafx.h"
#include "Client.h"
#include "KlineLeftView.h"
CKlineLeftView *Lv;
int IDpoint=0;
int M_IDpoint=0;
IMPLEMENT_DYNCREATE(CKlineLeftView, CFormView)
CKlineLeftView::CKlineLeftView()
: CFormView(CKlineLeftView::IDD)
{
}
CKlineLeftView::~CKlineLeftView()
{
}
void CKlineLeftView::DoDataExchange(CDataExchange *pDX)
{
CFormView::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CKlineLeftView, CFormView)
ON_WM_SIZE()
ON_WM_CREATE()
ON_WM_TIMER()
END_MESSAGE_MAP()
#ifdef _DEBUG
void CKlineLeftView::AssertValid() const
{
CFormView::AssertValid();
}
#ifndef _WIN32_WCE
void CKlineLeftView::Dump(CDumpContext &dc) const
{
CFormView::Dump(dc);
}
#endif
#endif
void CKlineLeftView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
}
void CKlineLeftView::OnDraw(CDC *pDC)
{
GetClientRect(&rect);
pDC->FillSolidRect(&rect, RGB(0,0,0));
rect.DeflateRect(0,40,0,0);
this->RePaint();
}
void CKlineLeftView::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);
}
void CKlineLeftView::Updata(int IDP)
{
if(IDP>0)
{
IDpoint=IDP;
M_IDpoint=0;
}
else if(IDP<0)
{
M_IDpoint=-IDP;
IDpoint=0;
}
else
{
M_IDpoint=0;
IDpoint=0;
}
CString str;
str.Format("%d------%d\n",IDpoint,M_IDpoint);
}
int CKlineLeftView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFormView::OnCreate(lpCreateStruct) == -1)
return -1;
SetTimer(1,300,NULL);
Lv = this;
return 0;
}
void CKlineLeftView::RePaint(void)
{
CDC* pDC;
pDC = GetWindowDC();
pDC->FillSolidRect(&rect, RGB(20, 32, 52));
CPen PenBlueTop(PS_SOLID,5,RGB(23,65,102));
pDC->SelectObject(&PenBlueTop);
pDC->MoveTo(rect.left,rect.top);
pDC->LineTo(rect.right,rect.top);
int liStart=rect.top + 20;
int SpaLine=80;
CClientDoc *pDoc = (CClientDoc *)GetDocument();
CFont font;
font.CreatePointFont(110, "微软雅黑");
pDC->SelectObject(&font);
SetTextColor(*pDC, RGB(255, 255, 255));
SetBkMode(*pDC, TRANSPARENT);
pDC->TextOut(rect.left + 5, liStart, "开盘价");
pDC->TextOut(rect.left + 5, liStart+SpaLine*1, "最高价");
pDC->TextOut(rect.left + 5, liStart+SpaLine*2, "最低价");
pDC->TextOut(rect.left + 5, liStart+SpaLine*3, "收盘价");
liStart=liStart+SpaLine*4+40;
pDC->TextOut(rect.left + 5, liStart, "成交量");
pDC->TextOut(rect.left + 5, liStart+SpaLine*1, "持仓量");
pDC->TextOut(rect.left + 10, liStart+SpaLine*2, "结算");
}
void CKlineLeftView::OnTimer(UINT_PTR nIDEvent)
{
CDC* pDC;
pDC = GetWindowDC();
CClientDoc* pDoc = (CClientDoc*)GetDocument();
switch (nIDEvent)
{
case 1:
{
CString KH, KL, KO, KC, MCO, PCent;
CFont font;
font.CreatePointFont(110, "微软雅黑");
pDC->SelectObject(&font);
SetTextColor(*pDC, RGB(255, 255, 255));
SetBkMode(*pDC, TRANSPARENT);
int liStart=rect.top + 40;
int SpaLine=80;
CString str;
str.Format("%d------%d\n",IDpoint,M_IDpoint);
OutputDebugString(str);
if(IDpoint)
{
this->RePaint();
KH.Format("%.2f", pDoc->m_DataSrvToClient.at(IDpoint)->KHighestPrice);
KL.Format("%.2f", pDoc->m_DataSrvToClient.at(IDpoint)->KLowestPrice);
KO.Format("%.2f", pDoc->m_DataSrvToClient.at(IDpoint)->KOpenPrice);
KC.Format("%.2f", pDoc->m_DataSrvToClient.at(IDpoint)->KClosePrice);
if (IDpoint == 0)
SetTextColor(*pDC, RGB(255, 74, 102));
else if (pDoc->m_DataSrvToClient.at(IDpoint)->KOpenPrice >= pDoc->m_DataSrvToClient.at(IDpoint - 1)->KOpenPrice)
SetTextColor(*pDC, RGB(255, 74, 102));
else
SetTextColor(*pDC, RGB(34, 177, 54));
pDC->TextOut(rect.left + 3, liStart, KO);
if (pDoc->m_DataSrvToClient.at(IDpoint)->KHighestPrice >= pDoc->m_DataSrvToClient.at(IDpoint)->KOpenPrice)
SetTextColor(*pDC, RGB(255, 74, 102));
else
SetTextColor(*pDC, RGB(34, 177, 54));
pDC->TextOut(rect.left + 3, liStart+SpaLine*1, KH);
if (pDoc->m_DataSrvToClient.at(IDpoint)->KLowestPrice >= pDoc->m_DataSrvToClient.at(IDpoint)->KOpenPrice)
SetTextColor(*pDC, RGB(255, 74, 102));
else
SetTextColor(*pDC, RGB(34, 177, 54));
pDC->TextOut(rect.left + 3, liStart+SpaLine*2, KL);
if (pDoc->m_DataSrvToClient.at(IDpoint)->KClosePrice >= pDoc->m_DataSrvToClient.at(IDpoint)->KOpenPrice)
SetTextColor(*pDC, RGB(255, 74, 102));
else
SetTextColor(*pDC, RGB(34, 177, 54));
pDC->TextOut(rect.left + 3, liStart+SpaLine*3, KC);
float MinusCO = pDoc->m_DataSrvToClient.at(IDpoint)->KClosePrice - pDoc->m_DataSrvToClient.at(IDpoint)->KOpenPrice;
MCO.Format("%.2f", MinusCO);
PCent.Format("%.2f%%", MinusCO / pDoc->m_DataSrvToClient.at(IDpoint)->KOpenPrice);
pDC->TextOut(rect.left + 3, liStart+SpaLine*3+20, MCO);
pDC->TextOut(rect.left + 3, liStart+SpaLine*3+40, PCent);
liStart=liStart+SpaLine*4+40;
SetTextColor(*pDC, RGB(255, 242, 0));
pDC->TextOut(rect.left + 3, liStart, "65");
pDC->TextOut(rect.left + 3, liStart+20, "8");
pDC->TextOut(rect.left + 3, liStart+SpaLine*1, "31891");
pDC->TextOut(rect.left + 3, liStart+SpaLine*1+20, "24");
pDC->TextOut(rect.left + 3, liStart+SpaLine*2, "3434.0");
}
else if(M_IDpoint)
{
this->RePaint();
KH.Format("%.2f",pDoc->m_DataKLine[M_IDpoint].KHighestPrice);
KL.Format("%.2f",pDoc->m_DataKLine[M_IDpoint].KLowestPrice);
KO.Format("%.2f",pDoc->m_DataKLine[M_IDpoint].KOpenPrice);
KC.Format("%.2f",pDoc->m_DataKLine[M_IDpoint].KClosePrice);
if(IDpoint==0)
SetTextColor(*pDC, RGB(255,74,102));
else if(pDoc->m_DataKLine[M_IDpoint].KOpenPrice>=pDoc->m_DataKLine[M_IDpoint-1].KOpenPrice)
SetTextColor(*pDC, RGB(255,74,102));
else
SetTextColor(*pDC, RGB(34,177,54));
pDC->TextOut(rect.left+3,liStart,KO);
if(pDoc->m_DataKLine[M_IDpoint].KHighestPrice>=pDoc->m_DataKLine[M_IDpoint].KOpenPrice)
SetTextColor(*pDC, RGB(255,74,102));
else
SetTextColor(*pDC, RGB(34,177,54));
pDC->TextOut(rect.left+3,liStart+SpaLine*1,KH);
if(pDoc->m_DataKLine[M_IDpoint].KLowestPrice>=pDoc->m_DataKLine[M_IDpoint].KOpenPrice)
SetTextColor(*pDC, RGB(255,74,102));
else
SetTextColor(*pDC, RGB(34,177,54));
pDC->TextOut(rect.left+3,liStart+SpaLine*2,KL);
if(pDoc->m_DataKLine[M_IDpoint].KClosePrice>=pDoc->m_DataKLine[M_IDpoint].KOpenPrice)
SetTextColor(*pDC, RGB(255,74,102));
else
SetTextColor(*pDC, RGB(34,177,54));
pDC->TextOut(rect.left+3,liStart+SpaLine*3,KC);
float MinusCO = pDoc->m_DataKLine[M_IDpoint].KClosePrice - pDoc->m_DataKLine[M_IDpoint].KOpenPrice;
MCO.Format("%.2f",MinusCO);
PCent.Format("%.2f%%",MinusCO/pDoc->m_DataKLine[M_IDpoint].KOpenPrice);
pDC->TextOut(rect.left+3,liStart+SpaLine