📄 mylistview.cpp
字号:
// MyListView.cpp : implementation file
//
#include "stdafx.h"
#include "stocksystem.h"
#include "MyListView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMyListView
IMPLEMENT_DYNCREATE(CMyListView, CListView)
CMyListView::CMyListView()
{
}
CMyListView::~CMyListView()
{
}
BEGIN_MESSAGE_MAP(CMyListView, CListView)
//{{AFX_MSG_MAP(CMyListView)
ON_WM_RBUTTONDOWN()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyListView drawing
void CMyListView::OnDraw(CDC* pDC)
{
CDocument* pDoc = GetDocument();
// TODO: add draw code here
}
/////////////////////////////////////////////////////////////////////////////
// CMyListView diagnostics
#ifdef _DEBUG
void CMyListView::AssertValid() const
{
CListView::AssertValid();
}
void CMyListView::Dump(CDumpContext& dc) const
{
CListView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMyListView message handlers
void CMyListView::OnInitialUpdate()
{
CListView::OnInitialUpdate();
CListCtrl &listctrl = this->GetListCtrl();
listctrl.ModifyStyle(0, LVS_REPORT);
listctrl.SetExtendedStyle(listctrl.GetExtendedStyle() | LVS_EX_GRIDLINES);
CString str[11] = {"序号", "代码", "名称", "持仓量", "市值", "成本价", "最新价", \
"浮动盈亏","总盈利率", "开仓日期", "市场"};
int i;
for (i = 0; i < 11; i++)
{
listctrl.InsertColumn(i, str[i], LVCFMT_LEFT, 80);
}
CListCtrl& m_list = GetListCtrl();
m_list.SetExtendedStyle(LVS_EX_FULLROWSELECT);
}
void CMyListView::OnRButtonDown(UINT nFlags, CPoint point)
{
CMenu menu;
if(!menu.LoadMenu(IDR_MENU)){
MessageBox("加载菜单失败");
}
CMenu* pM = menu.GetSubMenu(2);
CPoint pt ;
GetCursorPos(&pt);
pM->TrackPopupMenu(TPM_LEFTALIGN |TPM_LEFTBUTTON, pt.x, pt.y,GetParent()->GetParent());
// CListView::OnRButtonDown(nFlags, point);
}
void CMyListView::AddDealInfo(StockDealList &listbuf, int i)
{
CListCtrl& m_list = GetListCtrl();
CString textstr;
int temp;
temp = i+1;
textstr.Format("%d", temp);
m_list.InsertItem(i, textstr);
textstr.Empty();
textstr.Format("%s", listbuf.stockcode);
m_list.SetItemText(i, 1, textstr);
textstr.Empty();
textstr.Format("%s", listbuf.stockname);
m_list.SetItemText(i, 2, textstr);
textstr.Empty();
textstr.Format("%d", listbuf.stock_amount);
m_list.SetItemText(i, 3, textstr);
textstr.Empty();
textstr.Format("%.2f", listbuf.mart_value);
m_list.SetItemText(i, 4, textstr);
textstr.Empty();
textstr.Format("%.2f", listbuf.cost_price);
m_list.SetItemText(i, 5, textstr);
textstr.Empty();
textstr.Format("%.2f", listbuf.price);
m_list.SetItemText(i, 6, textstr);
textstr.Empty();
textstr.Format("%.2f", listbuf.profit_lost);
m_list.SetItemText(i, 7, textstr);
textstr.Empty();
textstr.Format("%.2f", listbuf.payoff_odds);
m_list.SetItemText(i, 8, textstr);
textstr.Empty();
textstr.Format("%s", listbuf.date);
m_list.SetItemText(i, 9, textstr);
textstr.Empty();
textstr.Format("%s", listbuf.deal_mart);
m_list.SetItemText(i, 10, textstr);
textstr.Empty();
//
// CString stockcode; //股票代码
// CString stockname; //股票名称
// int stock_amount; //持仓量
// double mart_value; //市场价值、市值=成本价*持仓量
// double cost_price; //成本价
// double price; //最新价
// double profit_lost; //盈亏
// double payoff_odds; //盈利率
// CString date; //开仓日期
// CString deal_mart; //交易市场
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -