www.pudn.com > NiHe > NiHeFormView.cpp


// NiHeFormView.cpp : implementation of the CNiHeFormView class 
// 
 
#include "stdafx.h" 
#include "NiHe.h" 
 
#include "NiHeDoc.h" 
#include "NiHeFromView.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CNiHeFormView 
 
IMPLEMENT_DYNCREATE(CNiHeFormView, CFormView) 
 
BEGIN_MESSAGE_MAP(CNiHeFormView, CFormView) 
	//{{AFX_MSG_MAP(CNiHeFormView) 
	ON_BN_CLICKED(IDC_TIANJIA, OnTianjia) 
	ON_BN_CLICKED(IDC_OK, OnOk) 
	//}}AFX_MSG_MAP 
	// Standard printing commands 
	ON_COMMAND(ID_FILE_PRINT, CFormView::OnFilePrint) 
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CFormView::OnFilePrint) 
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CFormView::OnFilePrintPreview) 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CNiHeFormView construction/destruction 
 
CNiHeFormView::CNiHeFormView() 
	: CFormView(CNiHeFormView::IDD) 
{ 
	//{{AFX_DATA_INIT(CNiHeFormView) 
	m_x = 0.0f; 
	m_y = 0.0f; 
	m_count = 0; 
 
	//}}AFX_DATA_INIT 
	// TODO: add construction code here 
 
} 
 
CNiHeFormView::~CNiHeFormView() 
{ 
} 
 
void CNiHeFormView::DoDataExchange(CDataExchange* pDX) 
{ 
	CFormView::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CNiHeFormView) 
	DDX_Text(pDX, IDC_X, m_x); 
	DDX_Text(pDX, IDC_Y, m_y); 
	DDX_Text(pDX, IDC_COUNT, m_count); 
	//}}AFX_DATA_MAP 
} 
 
BOOL CNiHeFormView::PreCreateWindow(CREATESTRUCT& cs) 
{ 
	// TODO: Modify the Window class or styles here by modifying 
	//  the CREATESTRUCT cs 
	return CFormView::PreCreateWindow(cs); 
} 
 
void CNiHeFormView::OnInitialUpdate() 
{ 
	CNiHeDoc *pDoc; 
	pDoc=GetDocument(); 
	ASSERT_VALID(pDoc); 
	m_count=pDoc->count; 
	CFormView::OnInitialUpdate(); 
	ResizeParentToFit(); 
 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CNiHeFormView printing 
 
BOOL CNiHeFormView::OnPreparePrinting(CPrintInfo* pInfo) 
{ 
	// default preparation 
	return DoPreparePrinting(pInfo); 
} 
 
void CNiHeFormView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) 
{ 
	// TODO: add extra initialization before printing 
} 
 
void CNiHeFormView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) 
{ 
	// TODO: add cleanup after printing 
} 
 
void CNiHeFormView::OnPrint(CDC* pDC, CPrintInfo* /*pInfo*/) 
{ 
	// TODO: add customized printing code here 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CNiHeFormView diagnostics 
 
#ifdef _DEBUG 
void CNiHeFormView::AssertValid() const 
{ 
	CFormView::AssertValid(); 
} 
 
void CNiHeFormView::Dump(CDumpContext& dc) const 
{ 
	CFormView::Dump(dc); 
} 
 
CNiHeDoc* CNiHeFormView::GetDocument() // non-debug version is inline 
{ 
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CNiHeDoc))); 
	return (CNiHeDoc*)m_pDocument; 
} 
#endif //_DEBUG 
 
///////////////////////////////////////////////////////////////////////////// 
// CNiHeFormView message handlers 
 
void CNiHeFormView::OnTianjia()  
{ 
	// TODO: Add your control notification handler code here 
	CNiHeDoc *pDoc; 
	pDoc=GetDocument(); 
	ASSERT_VALID(pDoc); 
	UpdateData(true);                //视图获取数据 
	m_count++; 
	pDoc->points[m_count].x=m_x;     //数据存档 
	pDoc->points[m_count].y=m_y; 
	pDoc->count=m_count; 
	UpdateData(false); 
} 
 
void CNiHeFormView::OnOk()  
{ 
	// TODO: Add your control notification handler code here 
	CNiHeDoc *pDoc; 
	pDoc=GetDocument(); 
	ASSERT_VALID(pDoc); 
	 
	pDoc->UpdateAllViews(this);      //更新所有视图 
}