Visual C++ Program for the Implementation of Full Server | CS1255 - Visual Programming Laboratory

AIM:
To write a Visual C++ Program for the Implementation of Full Server in CS1255 - Visual Programming Lab.

SOURCE CODE:
FULLSERVERDoc.h: Interface of the CFULLSERVERDoc class
#if !defined(AFX_FULLSERVERDOC_H__22785E62_66D8_4135_BB2A_8308ED217D3F__INCLUDED_)
#define AFX_FULLSERVERDOC_H__22785E62_66D8_4135_BB2A_8308ED217D3F__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CFULLSERVERSrvrItem;
class CFULLSERVERDoc : public COleServerDoc
{
protected: // create from serialization only
    CFULLSERVERDoc();
    DECLARE_DYNCREATE(CFULLSERVERDoc)
// Attributes
public:
    CFULLSERVERSrvrItem* GetEmbeddedItem()
        { return (CFULLSERVERSrvrItem*)COleServerDoc::GetEmbeddedItem(); }
// Operations
public:
    CString m_strText;
public:
// Overrides

    // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(CFULLSERVERDoc)
    protected:
    virtual COleServerItem* OnGetEmbeddedItem();
    public:
    virtual BOOL OnNewDocument();
    virtual void Serialize(CArchive& ar);
    //}}AFX_VIRTUAL
// Implementation
public:
    virtual ~CFULLSERVERDoc();
#ifdef _DEBUG
    virtual void AssertValid() const;
    virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Generated message map functions
protected:
    //{{AFX_MSG(CFULLSERVERDoc)
    afx_msg void OnModify();
    //}}AFX_MSG
    DECLARE_MESSAGE_MAP()
};

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

#endif // !defined(AFX_FULLSERVERDOC_H__22785E62_66D8_4135_BB2A_8308ED217D3F__INCLUDED_)

FULLSERVERDoc.cpp: Implementation of the CFULLSERVERDoc class
#include "stdafx.h"
#include "FULLSERVER.h"
#include "Textdialog.h"
#include "FULLSERVERDoc.h"
#include "SrvrItem.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
// CFULLSERVERDoc
IMPLEMENT_DYNCREATE(CFULLSERVERDoc, COleServerDoc)
BEGIN_MESSAGE_MAP(CFULLSERVERDoc, COleServerDoc)
    //{{AFX_MSG_MAP(CFULLSERVERDoc)
    ON_COMMAND(ID_MODIFY, OnModify)
    //}}AFX_MSG_MAP
END_MESSAGE_MAP()

// CFULLSERVERDoc construction/destruction

CFULLSERVERDoc::CFULLSERVERDoc()
{
    // Use OLE compound files
    EnableCompoundFile();
}

CFULLSERVERDoc::~CFULLSERVERDoc()
{
}

BOOL CFULLSERVERDoc::OnNewDocument()
{
    if (!COleServerDoc::OnNewDocument())
        return FALSE;
    // TODO: add reinitialization code here
    // (SDI documents will reuse this document)
    return TRUE;
}

// CFULLSERVERDoc server implementation

COleServerItem* CFULLSERVERDoc::OnGetEmbeddedItem()
{
    // OnGetEmbeddedItem is called by the framework to get the COleServerItem
    //  that is associated with the document.  It is only called when necessary.
    CFULLSERVERSrvrItem* pItem = new CFULLSERVERSrvrItem(this);
    ASSERT_VALID(pItem);
    return pItem;
}
// CFULLSERVERDoc serialization

void CFULLSERVERDoc::Serialize(CArchive& ar)
{          if (ar.IsStoring())
    {
        // TODO: add storing code here
    }
    else
    {
        // TODO: add loading code here
    }
}
// CFULLSERVERDoc diagnostics
#ifdef _DEBUG
void CFULLSERVERDoc::AssertValid() const
{
    COleServerDoc::AssertValid();
}
void CFULLSERVERDoc::Dump(CDumpContext& dc) const
{
    COleServerDoc::Dump(dc);
}
#endif //_DEBUG
// CFULLSERVERDoc commands

void CFULLSERVERDoc::OnModify()
{
    CTextDialog dlg;
    dlg.m_strText=m_strText;
    if(dlg.DoModal()==IDOK)
    {
                m_strText=dlg.m_strText;
        UpdateAllViews(NULL);
                UpdateAllItems(NULL);  SetModifiedFlag();
   }
}


FULLSERVERView.cpp: Implementation of the CFULLSERVERView class
#include "stdafx.h"
#include "FULLSERVER.h"
#include "TextDialog.h"
#include "FULLSERVERDoc.h"
#include "FULLSERVERView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
// CFULLSERVERView
IMPLEMENT_DYNCREATE(CFULLSERVERView, CView)
BEGIN_MESSAGE_MAP(CFULLSERVERView, CView)
    //{{AFX_MSG_MAP(CFULLSERVERView)
        // NOTE - the ClassWizard will add and remove mapping macros here.
        //    DO NOT EDIT what you see in these blocks of generated code!
    ON_COMMAND(ID_CANCEL_EDIT_SRVR, OnCancelEditSrvr)
    //}}AFX_MSG_MAP
END_MESSAGE_MAP()
// CFULLSERVERView construction/destruction
CFULLSERVERView::CFULLSERVERView()
{
    // TODO: add construction code here
}

CFULLSERVERView::~CFULLSERVERView()
{
}

BOOL CFULLSERVERView::PreCreateWindow(CREATESTRUCT& cs)
{
    // TODO: Modify the Window class or styles here by modifying
    //  the CREATESTRUCT cs
    return CView::PreCreateWindow(cs);
}
// CFULLSERVERView drawing

void CFULLSERVERView::OnDraw(CDC* pDC)
{
    CFULLSERVERDoc* pDoc = GetDocument();
    ASSERT_VALID(pDoc);
    // TODO: add draw code for native data here
    CFont font;
 font.CreateFont(-500,0,0,0,400,FALSE,FALSE,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,
        DEFAULT_QUALITY,DEFAULT_PITCH|FF_SWISS,"Arial");
    CFont* pFont=pDC->SelectObject(&font);
    CRect rectClient;
    GetClientRect(rectClient);
    CSize sizeClient= rectClient.Size();
    pDC->DPtoHIMETRIC(&sizeClient);
    CRect rectEllipse(sizeClient.cx/2 - 1000,
        -sizeClient.cy/2 + 1000,
        sizeClient.cx/2 + 1000,
        -sizeClient.cy/2 - 1000);
    pDC->Ellipse(rectEllipse);
    pDC->TextOut(0,0,pDoc->m_strText);
    pDC->SelectObject(pFont);
}

// OLE Server support
// The following command handler provides the standard keyboard
//  user interface to cancel an in-place editing session.  Here,
//  the server (not the container) causes the deactivation.
void CFULLSERVERView::OnCancelEditSrvr()
{
    GetDocument()->OnDeactivateUI(FALSE);
}
// CFULLSERVERView diagnostics

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

void CFULLSERVERView::Dump(CDumpContext& dc) const
{
    CView::Dump(dc);
}

CFULLSERVERDoc* CFULLSERVERView::GetDocument() // non-debug version is inline
{
    ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CFULLSERVERDoc)));
    return (CFULLSERVERDoc*)m_pDocument;
}
#endif //_DEBUG

// CFULLSERVERView message handlers

void CFULLSERVERView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)
{
    // TODO: Add your specialized code here and/or call the base class
    pDC->SetMapMode(MM_HIMETRIC);   
    CView::OnPrepareDC(pDC, pInfo);
}


SrvrItem.cpp: Implementation of the CFULLSERVERSrvrItem class
#include "stdafx.h"
#include "FULLSERVER.h"
#include "FULLSERVERDoc.h"
#include "SrvrItem.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
// CFULLSERVERSrvrItem implementation
IMPLEMENT_DYNAMIC(CFULLSERVERSrvrItem, COleServerItem)
CFULLSERVERSrvrItem::CFULLSERVERSrvrItem(CFULLSERVERDoc* pContainerDoc)
    : COleServerItem(pContainerDoc, TRUE)
{
    // TODO: add one-time construction code here
    //  (eg, adding additional clipboard formats to the item's data source)
}

CFULLSERVERSrvrItem::~CFULLSERVERSrvrItem()
{
    // TODO: add cleanup code here
}

void CFULLSERVERSrvrItem::Serialize(CArchive& ar)
{
    // CFULLSERVERSrvrItem::Serialize will be called by the framework if
    //  the item is copied to the clipboard.  This can happen automatically
    //  through the OLE callback OnGetClipboardData.  A good default for
    //  the embedded item is simply to delegate to the document's Serialize
    //  function.  If you support links, then you will want to serialize
    //  just a portion of the document.
    if (!IsLinkedItem())
    {
        CFULLSERVERDoc* pDoc = GetDocument();
        ASSERT_VALID(pDoc);
        pDoc->Serialize(ar);
    }}

BOOL CFULLSERVERSrvrItem::OnGetExtent(DVASPECT dwDrawAspect, CSize& rSize)
{
    // Most applications, like this one, only handle drawing the content
    //  aspect of the item.  If you wish to support other aspects, such
    //  as DVASPECT_THUMBNAIL (by overriding OnDrawEx), then this
    //  implementation of OnGetExtent should be modified to handle the
    //  additional aspect(s).
               if (dwDrawAspect != DVASPECT_CONTENT)
        return COleServerItem::OnGetExtent(dwDrawAspect, rSize);
             // CFULLSERVERSrvrItem::OnGetExtent is called to get the extent in
    //  HIMETRIC units of the entire item.  The default implementation
    //  here simply returns a hard-coded number of units.
               CFULLSERVERDoc* pDoc = GetDocument();
            ASSERT_VALID(pDoc);
          // TODO: replace this arbitrary size
            rSize = CSize(3000, 3000);   // 3000 x 3000 HIMETRIC units
            return TRUE;
}

BOOL CFULLSERVERSrvrItem::OnDraw(CDC* pDC, CSize& rSize)
{
    // Remove this if you use rSize
    UNREFERENCED_PARAMETER(rSize);
           CFULLSERVERDoc* pDoc = GetDocument();
    ASSERT_VALID(pDoc);
           // TODO: set mapping mode and extent
    //  (The extent is usually the same as the size returned from OnGetExtent)
    pDC->SetMapMode(MM_ANISOTROPIC);
    pDC->SetWindowOrg(0,0);
    pDC->SetWindowExt(3000, 3000);
              pDC->SetMapMode(MM_ANISOTROPIC);
    pDC->SetWindowOrg(0,0);
    pDC->SetWindowExt(3000, 3000);
            CFont font;
    font.CreateFont(-  500,0,0,0,400,FALSE,FALSE,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,
        DEFAULT_QUALITY,DEFAULT_PITCH|FF_SWISS,"Arial");
    CFont* pFont=pDC->SelectObject(&font);
    CRect rectEllipse(CRect(500,-500,2500,-2500));
    pDC->Ellipse(rectEllipse);
    pDC->TextOut(0,0,pDoc->m_strText);
    pDC->SelectObject(pFont);
            return TRUE;
}
// CFULLSERVERSrvrItem diagnostics

#ifdef _DEBUG
void CFULLSERVERSrvrItem::AssertValid() const
{
    COleServerItem::AssertValid();
}

void CFULLSERVERSrvrItem::Dump(CDumpContext& dc) const
{
    COleServerItem::Dump(dc);
}
#endif

OUTPUT:
Previous
Next Post »

If you still didn't find what you're looking for, you can search this website below: