Google Search

Saturday, January 29, 2011

Multiple Document Interface 600459– Visual Programming Anna University lab manual download fourth semester


Multiple Document Interface 600459– Visual Programming Anna University lab manual download fourth semester
Aim:

          To create a MDI (Application Wizard) and to draw an ellipse inside the view window using Device Context.

Logical Description:

            Using wizards create a multiple document interface

Algorithm:

1.                  File – New – Projects tab – MFC Appwizard (exe) – Give the location name and the project name – ok

  1. Select Multiple Document option.
3.      Accept the defaults in the next four screens.
4.      Click the finish button – ok button.
[ProgramnameView.cpp and ProgramnameView.h files define the     CprogramnameView class, which is central to the application ]

5.      In the .cpp file , write the following code in the OnDraw function  
   void CprogramnameView :: OnDraw(CDC *pDC)
             PDC à TextOut(0,0, “Hello World “);
               PDC à SelectStockObject(GRAY_BRUSH);
               PDC à Ellipse(CRect(0,20,100,120));
These 3 are the member functions of the  application framework’s device context  class CDC.

6.      Build and execute the Application.


Source Code:

// 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)
                        // NOTE - the ClassWizard will add and remove mapping macros here.
                        //    DO NOT EDIT what you see in these blocks of generated code!
            //}}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()
{
            // TODO: add construction code here

}

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(0,0, "Hello World ");
                        pDC->SelectStockObject(GRAY_BRUSH);
                        pDC->Ellipse(CRect(0,20,100,120));
}

/////////////////////////////////////////////////////////////////////////////
// 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

0 comments:

Post a Comment