0% found this document useful (0 votes)
60 views

Program // Mouseeventsview - CPP: Implementation of The Cmouseeventsview Class

This C++ program defines a class called CMouseEventsView that handles mouse events. The class implements various mouse event handler functions like OnLButtonDown and OnRButtonUp that draw text to the screen on mouse clicks and releases. The class is derived from CView and handles mouse events by overriding default event handler functions.

Uploaded by

michael.ferraris
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views

Program // Mouseeventsview - CPP: Implementation of The Cmouseeventsview Class

This C++ program defines a class called CMouseEventsView that handles mouse events. The class implements various mouse event handler functions like OnLButtonDown and OnRButtonUp that draw text to the screen on mouse clicks and releases. The class is derived from CView and handles mouse events by overriding default event handler functions.

Uploaded by

michael.ferraris
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 6

PROGRAM

// MouseEventsView.cpp : implementation of the CMouseEventsView class

#include "stdafx.h"
#include "MouseEvents.h"
#include "MouseEventsDoc.h"
#include "MouseEventsView.h"

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

// CMouseEventsView

IMPLEMENT_DYNCREATE(CMouseEventsView, CView)

BEGIN_MESSAGE_MAP(CMouseEventsView, CView)
//{{AFX_MSG_MAP(CMouseEventsView)
ON_WM_LBUTTONDBLCLK()
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_RBUTTONDBLCLK()
ON_WM_RBUTTONDOWN()
ON_WM_RBUTTONUP()
//}}AFX_MSG_MAP
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()
/////////////////////////////////////////////////////////////////////////////
// CMouseEventsView construction/destruction
CMouseEventsView::CMouseEventsView()
{
// TODO: add construction code here
}

CMouseEventsView::~CMouseEventsView()
{
}

BOOL CMouseEventsView::PreCreateWindow(CREATESTRUCT& cs)


{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs

return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CMouseEventsView drawing

void CMouseEventsView::OnDraw(CDC* pDC)


{
CMouseEventsDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
// CMouseEventsView printing

BOOL CMouseEventsView::OnPreparePrinting(CPrintInfo* pInfo)


{
// default preparation
return DoPreparePrinting(pInfo);
}
void CMouseEventsView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo*
/*pInfo*/)
{
// TODO: add extra initialization before printing
}

void CMouseEventsView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)


{
// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CMouseEventsView diagnostics

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

void CMouseEventsView::Dump(CDumpContext& dc) const


{
CView::Dump(dc);
}
CMouseEventsDoc* CMouseEventsView::GetDocument() // non-debug version is
inline
{
ASSERT(m_pDocument-
>IsKindOf(RUNTIME_CLASS(CMouseEventsDoc)));
return (CMouseEventsDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CMouseEventsView message handlers
void CMouseEventsView::OnLButtonDblClk(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default

CDC* pDC=GetDC();
pDC->TextOut(100,100,"Left Mouse Double click !!");
ReleaseDC(pDC);
CView::OnLButtonDblClk(nFlags, point);
}

void CMouseEventsView::OnLButtonDown(UINT nFlags, CPoint point)


{
// TODO: Add your message handler code here and/or call default
CDC* pDC=GetDC();
pDC->TextOut(100,120,"Left Mouse Down !!");
ReleaseDC(pDC);
CView::OnLButtonDown(nFlags, point);
}

void CMouseEventsView::OnLButtonUp(UINT nFlags, CPoint point)


{
// TODO: Add your message handler code here and/or call default
CDC* pDC=GetDC();
pDC->TextOut(100,140,"Left Mouse Up !!");
ReleaseDC(pDC);
CView::OnLButtonUp(nFlags, point);
}

void CMouseEventsView::OnRButtonDblClk(UINT nFlags, CPoint point)


{
// TODO: Add your message handler code here and/or call default
CDC* pDC=GetDC();
pDC->TextOut(100,160,"Right Mouse Double click !!");
ReleaseDC(pDC);
CView::OnRButtonDblClk(nFlags, point);
}

void CMouseEventsView::OnRButtonDown(UINT nFlags, CPoint point)


{
// TODO: Add your message handler code here and/or call default
CDC* pDC=GetDC();
pDC->TextOut(100,180,"Right Mouse Down !!");
ReleaseDC(pDC);
CView::OnRButtonDown(nFlags, point);
}

void CMouseEventsView::OnRButtonUp(UINT nFlags, CPoint point)


{
// TODO: Add your message handler code here and/or call default
CDC* pDC=GetDC();
pDC->TextOut(100,200,"Right Mouse Up !!");
ReleaseDC(pDC);
CView::OnRButtonUp(nFlags, point);
}

OUTPUT

You might also like