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 |
---|
15 | static char THIS_FILE[] = __FILE__; |
---|
16 | #endif |
---|
17 | |
---|
18 | ///////////////////////////////////////////////////////////////////////////// |
---|
19 | // CModbucfgDoc |
---|
20 | |
---|
21 | IMPLEMENT_DYNCREATE(CModbucfgDoc, CDocument) |
---|
22 | |
---|
23 | BEGIN_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 |
---|
28 | END_MESSAGE_MAP() |
---|
29 | |
---|
30 | BEGIN_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 |
---|
35 | END_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} |
---|
42 | static const IID IID_IModbucfg = |
---|
43 | { 0xa3bad4a7, 0xf5ae, 0x11d1, { 0x8f, 0xe9, 0x6c, 0xd5, 0x4, 0xc1, 0xbc, 0x1 } }; |
---|
44 | |
---|
45 | BEGIN_INTERFACE_MAP(CModbucfgDoc, CDocument) |
---|
46 | INTERFACE_PART(CModbucfgDoc, IID_IModbucfg, Dispatch) |
---|
47 | END_INTERFACE_MAP() |
---|
48 | |
---|
49 | ///////////////////////////////////////////////////////////////////////////// |
---|
50 | // CModbucfgDoc construction/destruction |
---|
51 | |
---|
52 | CModbucfgDoc::CModbucfgDoc() |
---|
53 | { |
---|
54 | // TODO: add one-time construction code here |
---|
55 | |
---|
56 | EnableAutomation(); |
---|
57 | |
---|
58 | AfxOleLockApp(); |
---|
59 | } |
---|
60 | |
---|
61 | CModbucfgDoc::~CModbucfgDoc() |
---|
62 | { |
---|
63 | AfxOleUnlockApp(); |
---|
64 | } |
---|
65 | |
---|
66 | BOOL 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 | |
---|
84 | void 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 |
---|
100 | void CModbucfgDoc::AssertValid() const |
---|
101 | { |
---|
102 | CDocument::AssertValid(); |
---|
103 | } |
---|
104 | |
---|
105 | void CModbucfgDoc::Dump(CDumpContext& dc) const |
---|
106 | { |
---|
107 | CDocument::Dump(dc); |
---|
108 | } |
---|
109 | #endif //_DEBUG |
---|
110 | |
---|
111 | ///////////////////////////////////////////////////////////////////////////// |
---|
112 | // CModbucfgDoc commands |
---|
113 | |
---|
114 | void 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 | } |
---|