source: trunk/XSUC/ModbucfgDoc.cpp @ 11

Last change on this file since 11 was 11, checked in by marrucho, 11 years ago
File size: 3.0 KB
Line 
1// ModbucfgDoc.cpp : implementation of the CModbucfgDoc class
2//
3
4#include "stdafx.h"
5#include "Modbucfg.h"
6
7#include "ModbucfgDoc.h"
8#include "ModbucfgView.h"
9
10#include "globals.h"
11
12#ifdef _DEBUG
13#define new DEBUG_NEW
14#undef THIS_FILE
15static char THIS_FILE[] = __FILE__;
16#endif
17
18/////////////////////////////////////////////////////////////////////////////
19// CModbucfgDoc
20
21IMPLEMENT_DYNCREATE(CModbucfgDoc, CDocument)
22
23BEGIN_MESSAGE_MAP(CModbucfgDoc, CDocument)
24        //{{AFX_MSG_MAP(CModbucfgDoc)
25                // NOTE - the ClassWizard will add and remove mapping macros here.
26                //    DO NOT EDIT what you see in these blocks of generated code!
27        //}}AFX_MSG_MAP
28END_MESSAGE_MAP()
29
30BEGIN_DISPATCH_MAP(CModbucfgDoc, CDocument)
31        //{{AFX_DISPATCH_MAP(CModbucfgDoc)
32                // NOTE - the ClassWizard will add and remove mapping macros here.
33                //      DO NOT EDIT what you see in these blocks of generated code!
34        //}}AFX_DISPATCH_MAP
35END_DISPATCH_MAP()
36
37// Note: we add support for IID_IModbucfg to support typesafe binding
38//  from VBA.  This IID must match the GUID that is attached to the
39//  dispinterface in the .ODL file.
40
41// {A3BAD4A7-F5AE-11D1-8FE9-6CD504C1BC01}
42static const IID IID_IModbucfg =
43{ 0xa3bad4a7, 0xf5ae, 0x11d1, { 0x8f, 0xe9, 0x6c, 0xd5, 0x4, 0xc1, 0xbc, 0x1 } };
44
45BEGIN_INTERFACE_MAP(CModbucfgDoc, CDocument)
46        INTERFACE_PART(CModbucfgDoc, IID_IModbucfg, Dispatch)
47END_INTERFACE_MAP()
48
49/////////////////////////////////////////////////////////////////////////////
50// CModbucfgDoc construction/destruction
51
52CModbucfgDoc::CModbucfgDoc()
53{
54        // TODO: add one-time construction code here
55
56        EnableAutomation();
57
58        AfxOleLockApp();
59}
60
61CModbucfgDoc::~CModbucfgDoc()
62{
63        AfxOleUnlockApp();
64}
65
66BOOL CModbucfgDoc::OnNewDocument()
67{
68        if (!CDocument::OnNewDocument())
69                return FALSE;
70
71        if (gConnections.GetCount()<1) {
72                AfxMessageBox(_T("There are no connections to open new document"));
73                return FALSE;
74        }
75
76        return TRUE;
77}
78
79
80
81/////////////////////////////////////////////////////////////////////////////
82// CModbucfgDoc serialization
83
84void CModbucfgDoc::Serialize(CArchive& ar)
85{
86        if (ar.IsStoring())
87        {
88                // TODO: add storing code here
89        }
90        else
91        {
92                // TODO: add loading code here
93        }
94}
95
96/////////////////////////////////////////////////////////////////////////////
97// CModbucfgDoc diagnostics
98
99#ifdef _DEBUG
100void CModbucfgDoc::AssertValid() const
101{
102        CDocument::AssertValid();
103}
104
105void CModbucfgDoc::Dump(CDumpContext& dc) const
106{
107        CDocument::Dump(dc);
108}
109#endif //_DEBUG
110
111/////////////////////////////////////////////////////////////////////////////
112// CModbucfgDoc commands
113
114void CModbucfgDoc::OnCloseDocument() 
115{
116        // TODO: Add your specialized code here and/or call the base class
117        CWaitCursor wait;    // display wait cursor
118        POSITION pos = GetFirstViewPosition(); 
119        while (pos != NULL)   {
120      CModbucfgView* pModbucfgView = (CModbucfgView*)GetNextView(pos);   
121          pModbucfgView->Stop();
122          while (pModbucfgView->IsBusy()) {
123                  CThinThread::DoEvents();
124          }
125        }   
126        CDocument::OnCloseDocument();
127}
Note: See TracBrowser for help on using the repository browser.