【VC开源代码栏目提醒】:以下是网学会员为您推荐的VC开源代码-Ex06_6View.cpp,希望本篇文章对您学习有所帮助。
// Ex06_6View.cpp : implementation of the CEx06_6View class
//
#include "stdafx.h"
#include "Ex06_6.h"
#include "Ex06_6Doc.h"
#include "Ex06_6View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CEx06_6View
IMPLEMENT_DYNCREATE(CEx06_6View, CView)
BEGIN_MESSAGE_MAP(CEx06_6View, CView)
//{{AFX_MSG_MAP(CEx06_6View)
ON_COMMAND(ID_VIEW_BICON, OnViewBicon)
ON_COMMAND(ID_VIEW_SICON, OnViewSicon)
ON_COMMAND(ID_VIEW_LIST, OnViewList)
ON_COMMAND(ID_VIEW_REPORT, OnViewReport)
ON_UPDATE_COMMAND_UI(ID_VIEW_BICON, OnUpdateViewBicon)
ON_UPDATE_COMMAND_UI(ID_VIEW_SICON, OnUpdateViewSicon)
ON_UPDATE_COMMAND_UI(ID_VIEW_LIST, OnUpdateViewList)
ON_UPDATE_COMMAND_UI(ID_VIEW_REPORT, OnUpdateViewReport)
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
ON_NOTIFY(TVN_SELCHANGED, IDC_TREECTRL, OnSelchangedTree)//手工添加
ON_NOTIFY(NM_DBLCLK, IDC_TREECTRL, OnDblclkTree)//手工添加
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CEx06_6View construction/destruction
CEx06_6View::CEx06_6View()
{
// TODO: add construction code here
m_bBIcon=0;
m_bSIcon=0;
m_bList=0;
m_bReport=1;
}
CEx06_6View::~CEx06_6View()
{
}
BOOL CEx06_6View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CEx06_6View drawing
void CEx06_6View::OnDraw(CDC* pDC)
{
CEx06_6Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CEx06_6View printing
BOOL CEx06_6View::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CEx06_6View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CEx06_6View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CEx06_6View diagnostics
#ifdef _DEBUG
void CEx06_6View::AssertValid() const
{
CView::AssertValid();
}
void CEx06_6View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CEx06_6Doc* CEx06_6View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CEx06_6Doc)));
return (CEx06_6Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CEx06_6View message handlers
void CEx06_6View::OnInitialUpdate()
{
CView::OnInitialUpdate();
// TODO: Add your specialized code here and/or call the base class
CreateListCtrl();//创建列表控件
CreateTreeCtrl();//创建树形控件
}
void CEx06_6View::CreateListCtrl()//创建列表控件
{
m_ctrlSImageList.Create(16,16,false,1,0);
m_ctrlBImageList.Create(32,32,false,1,0);
HICON hIcon=::LoadIcon(AfxGetResourceHandle(),MAKEINTRESOURCE(IDI_ICONS));
m_ctrlSImageList.Add(hIcon);
hIcon=::LoadIcon(AfxGetResourceHandle(),MAKEINTRESOURCE(IDI_ICONB));
m_ctrlBImageList.Add(hIcon);
m_ctrlList.Create(WS_VISIBLE|WS_CHILD|WS_BORDER|LVS_REPORT|LVS_NOSORTHEADER|LVS_EDITLABELS,CRect(250,10,500,300),this,IDC_LISTCTRL);
m_ctrlList.SetImageList(&m_ctrlSImageList,LVSIL_SMALL);
m_ctrlList.SetImageList(&m_ctrlBImageList,LVSIL_NORMAL);
//创建
列表控件列
LV_COLUMN lvColumn;
lvColumn.mask=LVCF_FMT|LVCF_WIDTH|LVCF_TEXT|LVCF_SUBITEM;
lvColumn.fmt=LVCFMT_CENTER;
lvColumn.cx=75;
lvColumn.iSubItem=0;
lvColumn.pszText="班级";
m_ctrlList.InsertColumn(0,&lvColumn);
lvColumn.iSubItem=1;
lvColumn.pszText="人数";
m_ctrlList.InsertColumn(1,&lvColumn);
lvColumn.iSubItem=2;
lvColumn.pszText="班导师";
m_ctrlList.Inser