AIM:
To write a Visual C++/Windows SDK Program for the Implementation of MDI(Multi Document Interface) and GDI(Graphical Device Interface) Application in CS1255 - Visual Programming Lab.
SOURCE CODE:
To write a Visual C++/Windows SDK Program for the Implementation of MDI(Multi Document Interface) and GDI(Graphical Device Interface) Application in CS1255 - Visual Programming Lab.
SOURCE CODE:
MDIView.h: interface of the CMDIView class
#if !defined(AFX_MDIVIEW_H__B33DBC6D_C753_4677_85D5_681C399A0FD3__INCLUDED_)
#define AFX_MDIVIEW_H__B33DBC6D_C753_4677_85D5_681C399A0FD3__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CMDIView : public CView
{
protected: // create from serialization only
CMDIView();
DECLARE_DYNCREATE(CMDIView)
// Attributes
public:
CMDIDoc* GetDocument();
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMDIView)
public:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
//}}AFX_VIRTUAL
private:int m_ncolor;CRect m_nrectEllipse;
// Implementation
public:
virtual ~CMDIView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Generated message map functions
protected:
//{{AFX_MSG(CMDIView)
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#ifndef _DEBUG // debug version in MDIView.cpp
inline CMDIDoc* CMDIView::GetDocument()
{ return (CMDIDoc*)m_pDocument; }
#endif
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MDIVIEW_H__B33DBC6D_C753_4677_85D5_681C399A0FD3__INCLUDED_)
MDIView.cpp: implementation of the CMDIView class
#include "stdafx.h"
#include "MDI.h"
#include "MDIDoc.h"
#include "MDIView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
// CMDIView
IMPLEMENT_DYNCREATE(CMDIView, CView)
BEGIN_MESSAGE_MAP(CMDIView, CView)
//{{AFX_MSG_MAP(CMDIView)
ON_WM_LBUTTONDOWN()
//}}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()
// CMDIView construction/destruction
CMDIView::CMDIView():m_nrectEllipse(0,0,200,200){m_ncolor=GRAY_BRUSH;}
CMDIView::~CMDIView()
{
}
BOOL CMDIView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
// CMDIView drawing
void CMDIView::OnDraw(CDC* pDC)
{
CMDIDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
pDC->TextOut(200,200,"JEBASTIN J");CBrush brush;brush.CreateSolidBrush(RGB(rand()%256,rand()%256,rand()%256));pDC->SelectObject(brush);pDC->Rectangle(m_nrectEllipse);}
// CMDIView printing
BOOL CMDIView::OnPreparePrinting(CPrintInfo* pInfo)
{ // default preparation
return DoPreparePrinting(pInfo);
}
void CMDIView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CMDIView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
// CMDIView diagnostics
#ifdef _DEBUG
void CMDIView::AssertValid() const
{
CView::AssertValid();
}
void CMDIView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CMDIDoc* CMDIView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMDIDoc)));
return (CMDIDoc*)m_pDocument;
}
#endif //_DEBUG
// CMDIView message handlers
void CMDIView::OnLButtonDown(UINT nFlags, CPoint point){if (m_nrectEllipse.PtInRect(point)){ if(m_ncolor==GRAY_BRUSH){ m_ncolor=WHITE_BRUSH;}else{ m_ncolor=GRAY_BRUSH;}}InvalidateRect(m_nrectEllipse);CView::OnLButtonDown(nFlags, point);}
OUTPUT:
EmoticonEmoticon