gusucode.com > 智能连接线C#源码程序 > 智能连接线/testsmartlines/testSmartLines/testSmartLinesView.cpp
// testSmartLinesView.cpp : implementation of the CTestSmartLinesView class // #include "stdafx.h" #include "testSmartLines.h" #include "testSmartLinesDoc.h" #include "testSmartLinesView.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CTestSmartLinesView IMPLEMENT_DYNCREATE(CTestSmartLinesView, CView) BEGIN_MESSAGE_MAP(CTestSmartLinesView, CView) //{{AFX_MSG_MAP(CTestSmartLinesView) ON_WM_LBUTTONDOWN() ON_WM_SETCURSOR() //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CTestSmartLinesView construction/destruction CTestSmartLinesView::CTestSmartLinesView() { // TODO: add construction code here POINT begin; POINT end; begin.x=100; begin.y=100; end.x=300; end.y=100; CSmartLine line1(begin,end); m_lines.AddTrail(line1); begin.x=300; begin.y=100; end.x=300; end.y=300; CSmartLine line2(begin,end); m_lines.AddTrail(line2); begin.x=300; begin.y=300; end.x=500; end.y=300; CSmartLine line3(begin,end); m_lines.AddTrail(line3); begin.x=500; begin.y=300; end.x=500; end.y=500; CSmartLine line4(begin,end); m_lines.AddTrail(line4); begin.x=500; begin.y=500; end.x=700; end.y=500; CSmartLine line5(begin,end); m_lines.AddTrail(line5); begin.x=700; begin.y=500; end.x=700; end.y=200; CSmartLine line6(begin,end); m_lines.AddTrail(line6); } CTestSmartLinesView::~CTestSmartLinesView() { } BOOL CTestSmartLinesView::PreCreateWindow(CREATESTRUCT& cs) { // TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs return CView::PreCreateWindow(cs); } ///////////////////////////////////////////////////////////////////////////// // CTestSmartLinesView drawing void CTestSmartLinesView::OnDraw(CDC* pDC) { CTestSmartLinesDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); // TODO: add draw code for native data here m_lines.Draw(pDC); } ///////////////////////////////////////////////////////////////////////////// // CTestSmartLinesView diagnostics #ifdef _DEBUG void CTestSmartLinesView::AssertValid() const { CView::AssertValid(); } void CTestSmartLinesView::Dump(CDumpContext& dc) const { CView::Dump(dc); } CTestSmartLinesDoc* CTestSmartLinesView::GetDocument() // non-debug version is inline { ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CTestSmartLinesDoc))); return (CTestSmartLinesDoc*)m_pDocument; } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CTestSmartLinesView message handlers void CTestSmartLinesView::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default m_lines.Track(this,point); CView::OnLButtonDown(nFlags, point); } BOOL CTestSmartLinesView::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) { // TODO: Add your message handler code here and/or call default if (m_lines.OnSetCursor(pWnd,nHitTest)) { return TRUE; } return CView::OnSetCursor(pWnd, nHitTest, message); }