主题:怎么在VISUAL C++ 中找错误啊
比如这个就是错误的要怎么样才可以找到错误的地方呢?
// dsadfdsView.cpp : implementation of the CDsadfdsView class
//
#include "stdafx.h"
#include "dsadfds.h"
#include "dsadfdsDoc.h"
#include "dsadfdsView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDsadfdsView
IMPLEMENT_DYNCREATE(CDsadfdsView, CScrollView)
BEGIN_MESSAGE_MAP(CDsadfdsView, CScrollView)
//{{AFX_MSG_MAP(CDsadfdsView)
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_MOUSEMOVE()
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CScrollView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CScrollView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CScrollView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDsadfdsView construction/destruction
CDsadfdsView::CDsadfdsView():m_sizeellipse(100,-100),
m_sizeoffset(0,0),
m_pointtopleft(0,0)
{
m_bcapture=FALSE;
}
CDsadfdsView::~CDsadfdsView()
{
}
BOOL CDsadfdsView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CScrollView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CDsadfdsView drawing
void CDsadfdsView::OnDraw(CDC* pDC)
{
CBrush brushhatch(HS_DIAGCROSS,RGB(255,0,0);
CPoint point(0,0);
pDC->LPtoDP(&point);
pDC->SetBrushOrg(point);
pDC->SelectObject(&brushhatch);
pDC->Ellipse(CRect(m_pointtopleft,m_sizeellipse);
pDC->SelectStockObject(BLACK_BRUSH);
pDC->Rectangle(100,-100,200,-200);
}
void CDsadfdsView::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
CSize sizeTotal(800,1500);
CSize sizepage(sizeTotal.cx/2,sizeTotal.cy/2);
CSize sizeLine(sizeTotal.cx/50,sizeTotal.cy/50);
SetScrollSizes(MM_LOENGLISH, sizeTotal,sizepage,sizeLine);
}
/////////////////////////////////////////////////////////////////////////////
// CDsadfdsView printing
BOOL CDsadfdsView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CDsadfdsView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CDsadfdsView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CDsadfdsView diagnostics
#ifdef _DEBUG
void CDsadfdsView::AssertValid() const
{
CScrollView::AssertValid();
}
void CDsadfdsView::Dump(CDumpContext& dc) const
{
CScrollView::Dump(dc);
}
CDsadfdsDoc* CDsadfdsView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CDsadfdsDoc)));
return (CDsadfdsDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CDsadfdsView message handlers
void CDsadfdsView::OnLButtonDown(UINT nFlags, CPoint point)
{
CRect rectellipse(m_pointtopleft,m_sizeellipse);
CRgn circle;
CClientDC dc(this);
OnPrepareDC(&dc);
dc.LPtoDP(rectellipse);
circle.CreateEllipticRgnIndirect(rectellipse);
if(circle.PtInRegion(point)){
SetCapture();
m_bcapture=TURE;
CPoint pointtopleft(m_pointtopleft);
dc.LPtoDP(&pointtopleft);
m_sizeoffset=point-pointtopleft;
::SetCursor(::LoadCursor(NULL,IDC_CROSS);
}
void CDsadfdsView::OnLButtonUp(UINT nFlags, CPoint point)
{
if(m_bcapture){
::ReleaseCapture();
m_bcapture=FALSE;
}
}
void CDsadfdsView::OnMouseMove(UINT nFlags, CPoint point)
{
if(m_bcapture){
CClientDC dc(this);
OnPrepare(&dc);
CRect rectold(m_pointtopleft,m_sizeellipse);
dc.LPtoDP(rectold);
InvalidateRect(rectold,TRUE);
m_pointtopleft=point-m_sizeoffset;
dc.DPtoLP(&m_pointtopleft);
CRect rectnew(m_pointtopleft,m_sizeellipse);
dc.LPtoDP(rectnew);
InvalidateRect(rectnew,TRUE);
}
// dsadfdsView.cpp : implementation of the CDsadfdsView class
//
#include "stdafx.h"
#include "dsadfds.h"
#include "dsadfdsDoc.h"
#include "dsadfdsView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDsadfdsView
IMPLEMENT_DYNCREATE(CDsadfdsView, CScrollView)
BEGIN_MESSAGE_MAP(CDsadfdsView, CScrollView)
//{{AFX_MSG_MAP(CDsadfdsView)
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_MOUSEMOVE()
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CScrollView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CScrollView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CScrollView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDsadfdsView construction/destruction
CDsadfdsView::CDsadfdsView():m_sizeellipse(100,-100),
m_sizeoffset(0,0),
m_pointtopleft(0,0)
{
m_bcapture=FALSE;
}
CDsadfdsView::~CDsadfdsView()
{
}
BOOL CDsadfdsView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CScrollView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CDsadfdsView drawing
void CDsadfdsView::OnDraw(CDC* pDC)
{
CBrush brushhatch(HS_DIAGCROSS,RGB(255,0,0);
CPoint point(0,0);
pDC->LPtoDP(&point);
pDC->SetBrushOrg(point);
pDC->SelectObject(&brushhatch);
pDC->Ellipse(CRect(m_pointtopleft,m_sizeellipse);
pDC->SelectStockObject(BLACK_BRUSH);
pDC->Rectangle(100,-100,200,-200);
}
void CDsadfdsView::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
CSize sizeTotal(800,1500);
CSize sizepage(sizeTotal.cx/2,sizeTotal.cy/2);
CSize sizeLine(sizeTotal.cx/50,sizeTotal.cy/50);
SetScrollSizes(MM_LOENGLISH, sizeTotal,sizepage,sizeLine);
}
/////////////////////////////////////////////////////////////////////////////
// CDsadfdsView printing
BOOL CDsadfdsView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CDsadfdsView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CDsadfdsView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CDsadfdsView diagnostics
#ifdef _DEBUG
void CDsadfdsView::AssertValid() const
{
CScrollView::AssertValid();
}
void CDsadfdsView::Dump(CDumpContext& dc) const
{
CScrollView::Dump(dc);
}
CDsadfdsDoc* CDsadfdsView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CDsadfdsDoc)));
return (CDsadfdsDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CDsadfdsView message handlers
void CDsadfdsView::OnLButtonDown(UINT nFlags, CPoint point)
{
CRect rectellipse(m_pointtopleft,m_sizeellipse);
CRgn circle;
CClientDC dc(this);
OnPrepareDC(&dc);
dc.LPtoDP(rectellipse);
circle.CreateEllipticRgnIndirect(rectellipse);
if(circle.PtInRegion(point)){
SetCapture();
m_bcapture=TURE;
CPoint pointtopleft(m_pointtopleft);
dc.LPtoDP(&pointtopleft);
m_sizeoffset=point-pointtopleft;
::SetCursor(::LoadCursor(NULL,IDC_CROSS);
}
void CDsadfdsView::OnLButtonUp(UINT nFlags, CPoint point)
{
if(m_bcapture){
::ReleaseCapture();
m_bcapture=FALSE;
}
}
void CDsadfdsView::OnMouseMove(UINT nFlags, CPoint point)
{
if(m_bcapture){
CClientDC dc(this);
OnPrepare(&dc);
CRect rectold(m_pointtopleft,m_sizeellipse);
dc.LPtoDP(rectold);
InvalidateRect(rectold,TRUE);
m_pointtopleft=point-m_sizeoffset;
dc.DPtoLP(&m_pointtopleft);
CRect rectnew(m_pointtopleft,m_sizeellipse);
dc.LPtoDP(rectnew);
InvalidateRect(rectnew,TRUE);
}