www.pudn.com > HReportTest.rar > HReportTestView.cpp


// HReportTestView.cpp : implementation of the CHReportTestView class 
// 
 
#include "stdafx.h" 
#include "HReportTest.h" 
 
#include "HReportTestDoc.h" 
#include "HReportTestView.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CHReportTestView 
 
IMPLEMENT_DYNCREATE(CHReportTestView, CHReportListView) 
 
BEGIN_MESSAGE_MAP(CHReportTestView, CHReportListView) 
	//{{AFX_MSG_MAP(CHReportTestView) 
	ON_WM_CREATE() 
	//}}AFX_MSG_MAP 
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview) 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CHReportTestView construction/destruction 
 
CHReportTestView::CHReportTestView() 
{ 
} 
 
CHReportTestView::~CHReportTestView() 
{ 
} 
 
BOOL CHReportTestView::PreCreateWindow(CREATESTRUCT& cs) 
{ 
	// TODO: Modify the Window class or styles here by modifying 
	//  the CREATESTRUCT cs 
 
	return CHReportListView::PreCreateWindow(cs); 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CHReportTestView drawing 
 
void CHReportTestView::OnDraw(CDC* pDC) 
{ 
	CHReportTestDoc* pDoc = GetDocument(); 
	ASSERT_VALID(pDoc); 
	// TODO: add draw code for native data here 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CHReportTestView diagnostics 
 
#ifdef _DEBUG 
void CHReportTestView::AssertValid() const 
{ 
	CHReportListView::AssertValid(); 
} 
 
void CHReportTestView::Dump(CDumpContext& dc) const 
{ 
	CHReportListView::Dump(dc); 
} 
 
CHReportTestDoc* CHReportTestView::GetDocument() // non-debug version is inline 
{ 
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CHReportTestDoc))); 
	return (CHReportTestDoc*)m_pDocument; 
} 
#endif //_DEBUG 
 
///////////////////////////////////////////////////////////////////////////// 
// CHReportTestView message handlers 
 
int CHReportTestView::OnCreate(LPCREATESTRUCT lpCreateStruct)  
{ 
	if (CHReportListView::OnCreate(lpCreateStruct) == -1) 
		return -1; 
	 
	CListCtrl& list = GetListCtrl(); 
	int iCol = 0; 
	list.InsertColumn(iCol++, "列Col1", LVCFMT_LEFT, 100); 
	list.InsertColumn(iCol++, "列Col2", LVCFMT_LEFT, 100); 
	list.InsertColumn(iCol++, "列Col3", LVCFMT_LEFT, 100); 
	list.InsertColumn(iCol++, "列Col4", LVCFMT_LEFT, 100); 
 
	CString str; 
	for(int i=0; i<10; ++i) 
	{ 
		str.Format("Item%d", i); 
		list.InsertItem(i, str); 
 
		str.Format("我是中国人Item%d-1", i); 
		list.SetItemText(i, 1, str); 
		 
		str.Format("我是中国人Item%d-2", i); 
		list.SetItemText(i, 2, str); 
		 
		str.Format("Item%d-3", i); 
		list.SetItemText(i, 3, str); 
	} 
 
//	ShowGridLines(TRUE); 
//	SelectFullRow(TRUE); 
//	SetSingleSel(TRUE); 
 
	return 0; 
} 
 
void CHReportTestView::OnRclickImpl(CPoint pt, int nItem) 
{ 
	CString str; 
	str.Format("R %d", nItem); 
	AfxMessageBox(str); 
} 
 
 
void CHReportTestView::OnClickImpl(CPoint pt, int nItem) 
{ 
	Beep(3000, 100); 
} 
 
void CHReportTestView::OnDbClickImpl(CPoint pt, int nItem) 
{ 
	CString str; 
	str.Format("D %d", nItem); 
	AfxMessageBox(str); 
} 
 
BOOL CHReportTestView::OnCustomDrawItem(int nItem, COLORREF &clrText, COLORREF &clrTextBk) 
{ 
	if(nItem % 2 == 1) 
	{ 
		clrTextBk = RGB(0, 0, 255); 
		return FALSE; 
	} 
 
	return TRUE; 
} 
 
void CHReportTestView::OnCustomDrawSubItem(int nItem, int nSubItem, COLORREF &clrText, COLORREF &clrTextBk) 
{ 
	if(nSubItem % 2 == 1) 
	{ 
		clrTextBk = RGB(255, 255, 255); 
		clrText = RGB(0, 0, 255); 
	} 
	else 
	{ 
		clrTextBk = RGB(255, 0, 0); 
		clrText = RGB(0, 0, 0); 
	} 
} 
 
void CHReportTestView::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo)  
{	 
	CHReportListView::OnBeginPrinting(pDC, pInfo); 
} 
 
void CHReportTestView::OnEndPrinting(CDC* pDC, CPrintInfo* pInfo)  
{ 
	CHReportListView::OnEndPrinting(pDC, pInfo); 
} 
 
void CHReportTestView::OnPrint(CDC* pDC, CPrintInfo* pInfo)  
{	 
	CHReportListView::OnPrint(pDC, pInfo); 
} 
 
BOOL CHReportTestView::OnPreparePrinting(CPrintInfo* pInfo)  
{ 
	print.SetPageText(_T("签收情况表")); 
	return CHReportListView::OnPreparePrinting(pInfo); 
} 
 
void CHReportTestView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)  
{ 
	CHReportListView::OnPrepareDC(pDC, pInfo); 
}