⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 huaxianview.cpp

📁 vc与matlab联调
💻 CPP
字号:
// huaxianView.cpp : implementation of the CHuaxianView class
//

#include "stdafx.h"
#include "huaxian.h"

#include "huaxianDoc.h"
#include "huaxianView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CHuaxianView

IMPLEMENT_DYNCREATE(CHuaxianView, CView)

BEGIN_MESSAGE_MAP(CHuaxianView, CView)
	//{{AFX_MSG_MAP(CHuaxianView)
	ON_WM_LBUTTONDOWN()
	ON_WM_LBUTTONUP()
	ON_WM_MOUSEMOVE()
	//}}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)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CHuaxianView construction/destruction

CHuaxianView::CHuaxianView()
{
	// TODO: add construction code here
	m_ptOrigin=0;
	m_bDraw=FALSE;

}

CHuaxianView::~CHuaxianView()
{
}

BOOL CHuaxianView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CHuaxianView drawing

void CHuaxianView::OnDraw(CDC* pDC)
{
	CHuaxianDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);

	// TODO: add draw code for native data here
}

/////////////////////////////////////////////////////////////////////////////
// CHuaxianView printing

BOOL CHuaxianView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CHuaxianView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CHuaxianView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CHuaxianView diagnostics

#ifdef _DEBUG
void CHuaxianView::AssertValid() const
{
	CView::AssertValid();
}

void CHuaxianView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CHuaxianDoc* CHuaxianView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CHuaxianDoc)));
	return (CHuaxianDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CHuaxianView message handlers

void CHuaxianView::OnLButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	//MessageBox("view click");
	m_ptOrigin=point;
	m_bDraw=TRUE;
	CView::OnLButtonDown(nFlags, point);
}

void CHuaxianView::OnLButtonUp(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	
	/*HDC hdc;
	hdc=::GetDC(m_hWnd);
	MoveToEx(hdc,m_ptOrigin.x,m_ptOrigin.y,NULL);
	LineTo(hdc,point.x,point.y);
	::ReleaseDC(m_hWnd,hdc);*/
    

	
	/*CPen pen(PS_SOLID,10,RGB(0,255,0));
	CClientDC dc(this);
	CPen *pOldPen=dc.SelectObject(&pen);
	dc.MoveTo(m_ptOrigin);
	dc.LineTo(point);
	dc.SelectObject(pOldPen);*/



//	CBrush brush(RGB(255,0,0));
/*	CBitmap bitmap;
	bitmap.LoadBitmap(IDB_BITMAP1);
	CBrush brush(&bitmap);
	CClientDC dc(this);
	dc.FillRect(CRect(m_ptOrigin,point),&brush);*/	


	/*CClientDC dc(this);
	CBrush *pBrush=CBrush::FromHandle((HBRUSH)GetStockObject(NULL_BRUSH));
	CBrush *pOldBrush=dc.SelectObject(pBrush);
	dc.Rectangle(CRect(m_ptOrigin,point));
	dc.SelectObject(pOldBrush);*/
	m_bDraw=FALSE;
	CView::OnLButtonUp(nFlags, point);
}

void CHuaxianView::OnMouseMove(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	CClientDC dc(this);
	CPen pen(PS_SOLID,10,RGB(0,255,0));
	CPen *pOldPen=dc.SelectObject(&pen);
	if(m_bDraw==TRUE)
	{
		dc.MoveTo(m_ptOrigin);
		dc.LineTo(point);
		m_ptOrigin=point;
	}
	dc.SelectObject(pOldPen);
	CView::OnMouseMove(nFlags, point);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -