Multiple Document Interface Source code Windows SDK / Visual C++ Programming

Source code visual programming step by step Algorithm
VIEW.H
// john52View.h : interface of the Cjohn52View class
#if !defined(AFX_john52VIEW_H__5A302433_602C_4F64_9D17_FBA7D351BC28__INCLUDED_)
#define AFX_john52VIEW_H__5A302433_602C_4F64_9D17_FBA7D351BC28__INCLUDED
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class Cjohn52View : public CView
{

protected: // create from serialization only
Cjohn52View();
DECLARE_DYNCREATE(Cjohn52View)
// Attributes
public:
Cjohn52Doc* GetDocument();
private:
int m_ncolor;
CRect m_RectEllipse;

// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(Cjohn52View)
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
// Implementation
public:
virtual ~Cjohn52View();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Generated message map functions

protected:
//{{AFX_MSG(Cjohn52View)
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#ifndef _DEBUG // debug version in john52View.cpp
inline Cjohn52Doc* Cjohn52View::GetDocument()
{ return (Cjohn52Doc*)m_pDocument; }
#endif

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_john52VIEW_H__5A302433_602C_4F64_9D17_FBA7D351BC28__INCLUDED_)


VIEW.CPP

// john52View.cpp : implementation of the Cjohn52View class
#include "stdafx.h"
#include "john52.h"
#include "john52Doc.h"
#include "john52View.h"

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

// Cjohn52View
IMPLEMENT_DYNCREATE(Cjohn52View, CView)
BEGIN_MESSAGE_MAP(Cjohn52View, CView)
//{{AFX_MSG_MAP(Cjohn52View)
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()
// Cjohn52View construction/destruction

Cjohn52View::Cjohn52View():m_RectEllipse(100,100,200,300)
{

m_ncolor=BLACK_BRUSH;
}

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

return CView::PreCreateWindow(cs);
}
// Cjohn52View drawing
void Cjohn52View::OnDraw(CDC* pDC)
{
Cjohn52Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
pDC->TextOut(10,10,"**john**");
pDC->SelectStockObject(m_ncolor);
pDC->Ellipse(m_RectEllipse);
}

// Cjohn52View printing

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

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

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

{
// TODO: add cleanup after printing
}
// Cjohn52View diagnostics
#ifdef _DEBUG
void Cjohn52View::AssertValid() const
{
CView::AssertValid();
}
void Cjohn52View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
Cjohn52Doc* Cjohn52View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(Cjohn52Doc)));
return (Cjohn52Doc*)m_pDocument;
}
#endif //_DEBUG

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

CView::OnLButtonDown(nFlags, point);
UpdateData(true);
if(m_RectEllipse.PtInRect(point))
{
if(m_ncolor==BLACK_BRUSH)
{
m_ncolor=GRAY_BRUSH;
}
else
{
m_ncolor=BLACK_BRUSH;
}
InvalidateRect(m_RectEllipse);
}
UpdateData(false);
}
Multiple Document Interface Screen Shot Step By Step Algorithm Output Multiple Document Interface Source code Windows SDK / Visual C++ Programming

Related post