|
// MFCDemoDoc.cpp : implementation of the CMFCDemoDoc class
//
// Author : David Shepherd
// Copyright (c) 2002, DaeDoe-Software
//
/////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "MFCDemo.h"
#include "MFCDemoDoc.h"
#include "MFCDemoView.h"
#include "LoadErrorDlg.h"
#include "Script.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMFCDemoDoc
IMPLEMENT_DYNCREATE(CMFCDemoDoc, CDocument)
BEGIN_MESSAGE_MAP(CMFCDemoDoc, CDocument)
//{{AFX_MSG_MAP(CMFCDemoDoc)
// 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
END_MESSAGE_MAP()
BEGIN_DISPATCH_MAP(CMFCDemoDoc, CDocument)
//{{AFX_DISPATCH_MAP(CMFCDemoDoc)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_DISPATCH_MAP
END_DISPATCH_MAP()
// Note: we add support for IID_IMFCDemo to support typesafe binding
// from VBA. This IID must match the GUID that is attached to the
// dispinterface in the .ODL file.
// {D458776D-EBFA-471A-B7FC-DA89B574C38C}
static const IID IID_IMFCDemo =
{ 0xd458776d, 0xebfa, 0x471a, { 0xb7, 0xfc, 0xda, 0x89, 0xb5, 0x74, 0xc3, 0x8c } };
BEGIN_INTERFACE_MAP(CMFCDemoDoc, CDocument)
INTERFACE_PART(CMFCDemoDoc, IID_IMFCDemo, Dispatch)
END_INTERFACE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMFCDemoDoc construction/destruction
CMFCDemoDoc::CMFCDemoDoc()
{
// TODO: add one-time construction code here
EnableAutomation();
AfxOleLockApp();
}
CMFCDemoDoc::~CMFCDemoDoc()
{
AfxOleUnlockApp();
}
BOOL CMFCDemoDoc::OnNewDocument()
{
BLOCK_BEGIN
if (!CDocument::OnNewDocument())
return FALSE;
// create a new form
POSITION Pos=GetFirstViewPosition();
ASSERT(Pos!=NULL);
CMFCDemoView *pView=(CMFCDemoView *)GetNextView(Pos);
ASSERT(pView!=NULL);
if(IsWindow(pView->m_FormEditor))
{
pView->m_FormEditor.New();
}
// set the script text
if(IsWindow(pView->m_FormEditor))
{
CScript Script=pView->m_FormEditor.GetScript();
Script.SetText(
_T("\' ----------------------------------------------------------------\r\n")
_T("\' This is the script editor provided by the standard DaeDoe Forms \r\n")
_T("\' package. If required, it can easily be replaced by a number of \r\n")
_T("\' powerful third party syntax highlighting editors such as CodeMax\r\n")
_T("\' and CodeSense. For additional information, please refer to the \r\n")
_T("\' DaeDoe Forms help manual. \r\n")
_T("\' ----------------------------------------------------------------\r\n"));
}
// reset the script editor modified flag
if(IsWindow(pView->m_SimpleScriptEditor))
{
pView->m_SimpleScriptEditor.SetModified(FALSE);
}
// reset the modified flag
SetModifiedFlag(FALSE);
BLOCK_END
return Caught ? FALSE : TRUE;
}
BOOL CMFCDemoDoc::OnOpenDocument(LPCTSTR lpszPathName)
{
BLOCK_BEGIN
if (!CDocument::OnOpenDocument(lpszPathName))
return FALSE;
// open a form
POSITION Pos=GetFirstViewPosition();
ASSERT(Pos!=NULL);
CMFCDemoView *pView=(CMFCDemoView *)GetNextView(Pos);
ASSERT(pView!=NULL);
if(IsWindow(pView->m_FormEditor))
{
pView->m_FormEditor.LoadFromFile(lpszPathName);
}
// reset the script editor modified flag
if(IsWindow(pView->m_SimpleScriptEditor))
{
pView->m_SimpleScriptEditor.SetModified(FALSE);
}
// reset the modified flag
SetModifiedFlag(FALSE);
BLOCK_END
// show the load error dialog
if(Caught)
{
CLoadErrorDlg Dlg;
(void)Dlg.DoModal();
}
return Caught ? FALSE : TRUE;
}
BOOL CMFCDemoDoc::OnSaveDocument(LPCTSTR lpszPathName)
{
BLOCK_BEGIN
if(!CDocument::OnSaveDocument(lpszPathName))
return FALSE;
// save a form
POSITION Pos=GetFirstViewPosition();
ASSERT(Pos!=NULL);
CMFCDemoView *pView=(CMFCDemoView *)GetNextView(Pos);
ASSERT(pView!=NULL);
if(IsWindow(pView->m_FormEditor))
{
pView->m_FormEditor.SaveToFile(lpszPathName);
}
// reset the script editor modified flag
if(IsWindow(pView->m_SimpleScriptEditor))
{
pView->m_SimpleScriptEditor.SetModified(FALSE);
}
// reset the modified flag
SetModifiedFlag(FALSE);
BLOCK_END
return Caught ? FALSE : TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CMFCDemoDoc serialization
void CMFCDemoDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
}
else
{
// TODO: add loading code here
}
}
/////////////////////////////////////////////////////////////////////////////
// CMFCDemoDoc diagnostics
#ifdef _DEBUG
void CMFCDemoDoc::AssertValid() const
{
CDocument::AssertValid();
}
void CMFCDemoDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMFCDemoDoc commands
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.