// Mymfc16Doc.cpp : implementation of the CMymfc16Doc class
//

#include "stdafx.h"
#include "mymfc16.h"

#include "Mymfc16Doc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

//////////////////////////////////////////////////////////////////////
// CMymfc16Doc

IMPLEMENT_DYNCREATE(CMymfc16Doc, CDocument)

BEGIN_MESSAGE_MAP(CMymfc16Doc, CDocument)
    //{{AFX_MSG_MAP(CMymfc16Doc)
    ON_COMMAND(ID_EDIT_CLEAR_ALL, OnEditClearAll)
    ON_UPDATE_COMMAND_UI(ID_EDIT_CLEAR_ALL, OnUpdateEditClearAll)
    //}}AFX_MSG_MAP
END_MESSAGE_MAP()

//////////////////////////////////////////////////////////////////////
// CMymfc16Doc construction/destruction

CMymfc16Doc::CMymfc16Doc()
{
    TRACE("Entering CMymfc16Doc constructor\n");
#ifdef _DEBUG
    afxDump.SetDepth(1); // Ensure dump of list elements
#endif // _DEBUG
}

CMymfc16Doc::~CMymfc16Doc()
{
}

BOOL CMymfc16Doc::OnNewDocument()
{
    TRACE("Entering CMymfc16Doc::OnNewDocument\n");
    if (!CDocument::OnNewDocument())
        return FALSE;

    // TODO: add re-initialization code here
    // (SDI documents will reuse this document)

    return TRUE;
}
//////////////////////////////////////////////////////////////////////
// CMymfc16Doc serialization

void CMymfc16Doc::Serialize(CArchive& ar)
{
    if (ar.IsStoring())
    {
        // TODO: add storing code here
    }
    else
    {
        // TODO: add loading code here
    }
}

//////////////////////////////////////////////////////////////////////
// CMymfc16Doc diagnostics

#ifdef _DEBUG
void CMymfc16Doc::AssertValid() const
{
    CDocument::AssertValid();
}

void CMymfc16Doc::Dump(CDumpContext& dc) const
{
    CDocument::Dump(dc);
    dc << "\n" << m_studentList << "\n";
}
#endif //_DEBUG

//////////////////////////////////////////////////////////////////////
// CMymfc16Doc commands

void CMymfc16Doc::DeleteContents() 
{
#ifdef _DEBUG
    Dump(afxDump);
#endif
    while (m_studentList.GetHeadPosition())
	{
        delete m_studentList.RemoveHead();
    }
}

void CMymfc16Doc::OnEditClearAll() 
{
    DeleteContents();
    UpdateAllViews(NULL);
}

void CMymfc16Doc::OnUpdateEditClearAll(CCmdUI* pCmdUI) 
{
    pCmdUI->Enable(!m_studentList.IsEmpty());
}

