📄 listviewexampleview.cpp
字号:
// ListViewExampleView.cpp : implementation of the CListViewExampleView class
//
#include "stdafx.h"
#include "ListViewExample.h"
#include "ListViewExampleDoc.h"
#include "ListViewExampleView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CListViewExampleView
IMPLEMENT_DYNCREATE(CListViewExampleView, CListView)
BEGIN_MESSAGE_MAP(CListViewExampleView, CListView)
//{{AFX_MSG_MAP(CListViewExampleView)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CListView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CListView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CListView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CListViewExampleView construction/destruction
CListViewExampleView::CListViewExampleView()
{
// TODO: add construction code here
}
CListViewExampleView::~CListViewExampleView()
{
}
BOOL CListViewExampleView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CListView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CListViewExampleView drawing
CString strdata[4][4]={"1","平平","经理","个人",
"2","凯特","职员","团体",
"3","杨某","经理","团体",
"4","刘某","职员","团体"
};
void CListViewExampleView::OnDraw(CDC* pDC)
{
CListViewExampleDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
void CListViewExampleView::OnInitialUpdate()
{
CListView::OnInitialUpdate();
CListCtrl *pListCtl=&GetListCtrl();
pListCtl->DeleteAllItems();
pListCtl->ModifyStyle(0L,LVS_REPORT);
pListCtl->SetExtendedStyle(LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT);
pListCtl->InsertColumn(0,"图像",LVCFMT_LEFT,100);
pListCtl->InsertColumn(1,"员工信息",LVCFMT_LEFT,150);
pListCtl->InsertColumn(2,"企业信息",LVCFMT_LEFT,150);
pListCtl->InsertColumn(3,"公司结构",LVCFMT_LEFT,150);
for(int p=0;p<4;p++)
{
pListCtl->InsertItem(p,"");
pListCtl->SetItemText(p,0,strdata[p][0]);
pListCtl->SetItemText(p,1,strdata[p][1]);
pListCtl->SetItemText(p,2,strdata[p][2]);
pListCtl->SetItemText(p,3,strdata[p][3]);
}
}
/////////////////////////////////////////////////////////////////////////////
// CListViewExampleView printing
BOOL CListViewExampleView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CListViewExampleView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CListViewExampleView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CListViewExampleView diagnostics
#ifdef _DEBUG
void CListViewExampleView::AssertValid() const
{
CListView::AssertValid();
}
void CListViewExampleView::Dump(CDumpContext& dc) const
{
CListView::Dump(dc);
}
CListViewExampleDoc* CListViewExampleView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CListViewExampleDoc)));
return (CListViewExampleDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CListViewExampleView message handlers
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -