提交 | 用户 | age
|
0ed438
|
1 |
|
Q |
2 |
// MainFrm.cpp: CMainFrame 类的实现
|
|
3 |
//
|
|
4 |
|
|
5 |
#include "pch.h"
|
|
6 |
#include "framework.h"
|
|
7 |
#include "MTerm2.h"
|
|
8 |
#include "MainFrm.h"
|
|
9 |
#include "ChildFrm.h"
|
|
10 |
|
|
11 |
#include "MTerm2Doc.h"
|
|
12 |
#include "MTerm2View.h"
|
|
13 |
#include "MTerm2CtrlView.h"
|
|
14 |
#include "MTerm2TestView.h"
|
|
15 |
#include "MTerm2ProgTxt.h"
|
|
16 |
|
|
17 |
#ifdef _DEBUG
|
|
18 |
#define new DEBUG_NEW
|
|
19 |
#endif
|
|
20 |
|
|
21 |
// CMainFrame
|
|
22 |
|
|
23 |
IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWndEx)
|
|
24 |
|
|
25 |
BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWndEx)
|
|
26 |
ON_WM_CREATE()
|
|
27 |
|
|
28 |
ON_COMMAND(ID_UPLOAD_FROM_PLC, &CMainFrame::OnUploadFromPlc)
|
|
29 |
ON_COMMAND(ID_VIEW_FUNCKEY_BAR, &CMainFrame::OnViewFunckeyBar)
|
|
30 |
ON_UPDATE_COMMAND_UI(ID_VIEW_FUNCKEY_BAR, &CMainFrame::OnUpdateViewFunckeyBar)
|
|
31 |
ON_COMMAND(ID_VIEW_INPUT_BAR, &CMainFrame::OnViewInputBar)
|
|
32 |
ON_UPDATE_COMMAND_UI(ID_VIEW_INPUT_BAR, &CMainFrame::OnUpdateViewInputBar)
|
|
33 |
ON_COMMAND(ID_VIEW_NUMKEY_BAR, &CMainFrame::OnViewNumkeyBar)
|
|
34 |
ON_UPDATE_COMMAND_UI(ID_VIEW_NUMKEY_BAR, &CMainFrame::OnUpdateViewNumkeyBar)
|
|
35 |
ON_COMMAND(ID_VIEW_INPUTSEG_BAR, &CMainFrame::OnViewInputsegBar)
|
|
36 |
ON_UPDATE_COMMAND_UI(ID_VIEW_INPUTSEG_BAR, &CMainFrame::OnUpdateViewInputsegBar)
|
|
37 |
ON_COMMAND(ID_VIEW_COMMENTS_BAR, &CMainFrame::OnViewCommentsBar)
|
|
38 |
ON_UPDATE_COMMAND_UI(ID_VIEW_COMMENTS_BAR, &CMainFrame::OnUpdateViewCommentsBar)
|
|
39 |
|
|
40 |
// ON_COMMAND(ID_MENU_VIEW_LDS, &CMainFrame::OnMenuViewLds)
|
|
41 |
// ON_COMMAND(ID_MENU_VIEW_BLD, &CMainFrame::OnMenuViewBld)
|
|
42 |
// ON_COMMAND(ID_MENU_VIEW_BNL, &CMainFrame::OnMenuViewBnl)
|
|
43 |
|
|
44 |
ON_COMMAND(ID_MENU_SHOW_LOG, &CMainFrame::OnMenuShowLog)
|
|
45 |
END_MESSAGE_MAP()
|
|
46 |
|
|
47 |
static UINT indicators[] =
|
|
48 |
{
|
|
49 |
ID_SEPARATOR, // 状态行指示器
|
|
50 |
ID_INDICATOR_SEL_TYPE,
|
|
51 |
ID_INDICATOR_CAPS,
|
|
52 |
ID_INDICATOR_NUM,
|
|
53 |
ID_INDICATOR_SCRL,
|
|
54 |
};
|
|
55 |
|
|
56 |
// CMainFrame 构造/析构
|
|
57 |
|
|
58 |
CMainFrame::CMainFrame() noexcept
|
|
59 |
{
|
|
60 |
// TODO: 在此添加成员初始化代码
|
|
61 |
}
|
|
62 |
|
|
63 |
CMainFrame::~CMainFrame()
|
|
64 |
{
|
|
65 |
}
|
|
66 |
|
|
67 |
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
|
|
68 |
{
|
|
69 |
if (CMDIFrameWndEx::OnCreate(lpCreateStruct) == -1)
|
|
70 |
return -1;
|
|
71 |
// m_dlgMyLog.Create(m_dlgMyLog.IDD, GetParent());
|
|
72 |
// m_dlgMyLog.ShowWindow(SW_SHOW);
|
|
73 |
|
65f713
|
74 |
// BOOL bNameValid;
|
Q |
75 |
|
|
76 |
// 创建类视图
|
|
77 |
CString strNavView;
|
|
78 |
// bNameValid = strNavView.LoadString(IDS_CLASS_VIEW);
|
|
79 |
// ASSERT(bNameValid);
|
|
80 |
strNavView = _T("导航视图");
|
|
81 |
if (!m_wndNavView.Create(strNavView, this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_NAVVIEW, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI))
|
|
82 |
{
|
|
83 |
TRACE0("未能创建“导航视图”窗口\n");
|
|
84 |
return FALSE; // 未能创建
|
|
85 |
}
|
|
86 |
|
0ed438
|
87 |
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
|
Q |
88 |
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
|
|
89 |
{
|
|
90 |
TRACE0("未能创建工具栏\n");
|
|
91 |
return -1; // 未能创建
|
|
92 |
}
|
|
93 |
|
326d3e
|
94 |
///* 输入栏
|
0ed438
|
95 |
if (!m_wndToolBar_InputShow.CreateEx(this, TBSTYLE_FLAT,
|
Q |
96 |
WS_CHILD | WS_VISIBLE | CBRS_BOTTOM | CBRS_FLOAT_MULTI | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC,
|
|
97 |
CRect(1, 1, 1, 1), IDW_TOOL_BAR2) ||
|
|
98 |
!m_wndToolBar_InputShow.LoadToolBar(IDR_TOOLBAR_INPUT_SHOW))
|
|
99 |
{
|
|
100 |
TRACE0("未能创建数字工具栏\n");
|
|
101 |
return -1; // 未能创建
|
|
102 |
}
|
|
103 |
//*/
|
|
104 |
CRect rect1;
|
|
105 |
int index = m_wndToolBar_InputShow.CommandToIndex(ID_BUTTON_INPUT_SHOW);
|
|
106 |
UINT nID,nStyle;
|
|
107 |
int iImage;
|
|
108 |
m_wndToolBar_InputShow.GetButtonInfo(0, nID, nStyle, iImage);
|
|
109 |
m_wndToolBar_InputShow.SetButtonInfo(index, ID_BUTTON_INPUT_SHOW, TBBS_SEPARATOR, 100);
|
|
110 |
m_wndToolBar_InputShow.GetItemRect(index, &rect1);
|
|
111 |
rect1.left = 1;
|
|
112 |
rect1.top = 2;
|
|
113 |
rect1.right = rect1.left + 100;
|
|
114 |
rect1.bottom = rect1.top + 20;
|
|
115 |
/*
|
|
116 |
if (!m_InputShowEdit.Create(WS_CHILD | WS_VISIBLE | WS_BORDER, rect1, \
|
|
117 |
&m_wndToolBar_InputShow, ID_BUTTON_INPUT_SHOW))
|
|
118 |
{
|
|
119 |
TRACE(_T("Failed to create CEdit\n"));
|
|
120 |
return FALSE;
|
|
121 |
}
|
|
122 |
//*/
|
|
123 |
if (!m_InputShowStatic.Create(_T("Test1"),WS_CHILD | WS_VISIBLE |WS_EX_CLIENTEDGE, rect1, \
|
|
124 |
&m_wndToolBar_InputShow, ID_BUTTON_INPUT_SHOW))
|
|
125 |
{
|
|
126 |
TRACE(_T("Failed to create CStaticEx\n"));
|
|
127 |
return FALSE;
|
|
128 |
}
|
|
129 |
m_InputShowStatic.SetBkColor(RGB(255, 255, 255));
|
|
130 |
m_InputShowStatic.SetTextColor(RGB(255, 128, 128));
|
|
131 |
m_InputShowStatic.SetTextSize(20);
|
|
132 |
|
|
133 |
//m_InputShowEdit.SetReadOnly(true);
|
|
134 |
///*
|
|
135 |
if (!m_wndToolBar_Num.CreateEx(this, TBSTYLE_FLAT,
|
|
136 |
WS_CHILD | WS_VISIBLE | CBRS_BOTTOM | CBRS_FLOAT_MULTI | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC,
|
|
137 |
CRect(1,1,1,1),IDW_TOOL_BAR2) ||
|
|
138 |
!m_wndToolBar_Num.LoadToolBar(IDR_TOOLBAR_NUM))
|
|
139 |
{
|
|
140 |
TRACE0("未能创建数字工具栏\n");
|
|
141 |
return -1; // 未能创建
|
|
142 |
}
|
|
143 |
//*/
|
|
144 |
|
|
145 |
///*
|
|
146 |
if (!m_wndToolBar_Edit.CreateEx(this, TBSTYLE_FLAT,
|
|
147 |
WS_CHILD | WS_VISIBLE | CBRS_BOTTOM | CBRS_FLOAT_MULTI | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC,
|
|
148 |
CRect(1, 1, 1, 1), IDW_TOOL_BAR_EDIT) ||
|
|
149 |
!m_wndToolBar_Edit.LoadToolBar(IDR_TOOLBAR_EDIT))
|
|
150 |
{
|
|
151 |
TRACE0("未能创建数字工具栏\n");
|
|
152 |
return -1; // 未能创建
|
|
153 |
}
|
|
154 |
//*/
|
|
155 |
|
|
156 |
|
|
157 |
if (!m_wndStatusBar.Create(this))
|
|
158 |
{
|
|
159 |
TRACE0("未能创建状态栏\n");
|
|
160 |
return -1; // 未能创建
|
|
161 |
}
|
|
162 |
m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT));
|
|
163 |
m_wndStatusBar.SetPaneStyle(0, SBPS_STRETCH);
|
|
164 |
// /*
|
|
165 |
|
|
166 |
if (!m_wndMyPaneLog.Create(_T("日志窗口"), this, CRect(0, 0, 200, 200), TRUE, 1235, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS
|
|
167 |
| WS_CLIPCHILDREN | CBRS_RIGHT | CBRS_FLOAT_MULTI))
|
|
168 |
{
|
|
169 |
TRACE0("未能创建“MyPaneLog窗口\n");
|
|
170 |
return FALSE;
|
|
171 |
}
|
|
172 |
|
|
173 |
//*/
|
|
174 |
// TODO: 如果不需要可停靠工具栏,则删除这三行
|
|
175 |
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
|
|
176 |
EnableDocking(CBRS_ALIGN_ANY);
|
|
177 |
DockPane(&m_wndToolBar);
|
|
178 |
|
|
179 |
|
|
180 |
m_wndMyPaneLog.EnableDocking(CBRS_ALIGN_ANY);
|
|
181 |
// EnableDocking(CBRS_ALIGN_ANY);
|
|
182 |
|
65f713
|
183 |
m_wndNavView.EnableDocking(CBRS_ALIGN_ANY);
|
Q |
184 |
DockPane(&m_wndNavView);
|
|
185 |
// CDockablePane* pTabbedBar = nullptr;
|
|
186 |
// m_wndNavView.AttachToTabWnd(&m_wndFileView, DM_SHOW, TRUE, &pTabbedBar);
|
|
187 |
|
0ed438
|
188 |
|
Q |
189 |
///*
|
|
190 |
m_wndToolBar_InputShow.EnableDocking(CBRS_ALIGN_ANY);
|
|
191 |
m_wndToolBar_Num.EnableDocking(CBRS_ALIGN_ANY);
|
|
192 |
m_wndToolBar_Edit.EnableDocking(CBRS_ALIGN_ANY);
|
|
193 |
|
|
194 |
EnableDocking(CBRS_ALIGN_ANY);
|
|
195 |
|
|
196 |
// DockPane(&m_wndToolBar);
|
|
197 |
|
|
198 |
DockPane(&m_wndToolBar_InputShow);
|
|
199 |
DockPane(&m_wndToolBar_Num);
|
|
200 |
DockPane(&m_wndToolBar_Edit);
|
|
201 |
|
|
202 |
DockPane(&m_wndMyPaneLog);
|
|
203 |
//*/
|
|
204 |
return 0;
|
|
205 |
}
|
|
206 |
|
|
207 |
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
|
|
208 |
{
|
|
209 |
if( !CMDIFrameWndEx::PreCreateWindow(cs) )
|
|
210 |
return FALSE;
|
|
211 |
// TODO: 在此处通过修改
|
|
212 |
// CREATESTRUCT cs 来修改窗口类或样式
|
|
213 |
|
|
214 |
return TRUE;
|
|
215 |
}
|
|
216 |
|
|
217 |
// CMainFrame 诊断
|
|
218 |
|
|
219 |
#ifdef _DEBUG
|
|
220 |
void CMainFrame::AssertValid() const
|
|
221 |
{
|
|
222 |
CMDIFrameWndEx::AssertValid();
|
|
223 |
}
|
|
224 |
|
|
225 |
void CMainFrame::Dump(CDumpContext& dc) const
|
|
226 |
{
|
|
227 |
CMDIFrameWndEx::Dump(dc);
|
|
228 |
}
|
|
229 |
#endif //_DEBUG
|
|
230 |
|
|
231 |
|
|
232 |
// CMainFrame 消息处理程序
|
|
233 |
|
|
234 |
|
|
235 |
|
|
236 |
void CMainFrame::OnUploadFromPlc()
|
|
237 |
{
|
|
238 |
// TODO: 在此添加命令处理程序代码
|
|
239 |
CWinAppEx* pApp = &theApp;
|
|
240 |
POSITION curTemplatePos = pApp->GetFirstDocTemplatePosition();
|
|
241 |
if (curTemplatePos != NULL)
|
|
242 |
{
|
|
243 |
CDocTemplate* curTemplate = pApp->GetNextDocTemplate(curTemplatePos);
|
|
244 |
curTemplate->OpenDocumentFile(NULL);
|
|
245 |
//CView* thisView = GetActiveView();
|
|
246 |
CMTerm2Doc* pDoc = (CMTerm2Doc*)GetActiveDocument();
|
|
247 |
// pDoc->OnNewDocument();
|
|
248 |
pDoc->OnUploadFromPlc();
|
|
249 |
}
|
|
250 |
//SysLog(_T("From mainframe"));
|
|
251 |
|
|
252 |
}
|
|
253 |
|
|
254 |
void CMainFrame::OnMenuShowLog()
|
|
255 |
{
|
|
256 |
// TODO: 在此添加命令处理程序代码
|
|
257 |
m_wndMyPaneLog.ShowWindow(SW_SHOW);
|
|
258 |
}
|
|
259 |
|
|
260 |
|
|
261 |
void CMainFrame::OnViewFunckeyBar()
|
|
262 |
{
|
|
263 |
// TODO: 在此添加命令处理程序代码
|
|
264 |
}
|
|
265 |
|
|
266 |
|
|
267 |
void CMainFrame::OnUpdateViewFunckeyBar(CCmdUI *pCmdUI)
|
|
268 |
{
|
|
269 |
// TODO: 在此添加命令更新用户界面处理程序代码
|
|
270 |
}
|
|
271 |
|
|
272 |
|
|
273 |
void CMainFrame::OnViewInputBar()
|
|
274 |
{
|
|
275 |
// TODO: 在此添加命令处理程序代码
|
|
276 |
}
|
|
277 |
|
|
278 |
|
|
279 |
void CMainFrame::OnUpdateViewInputBar(CCmdUI *pCmdUI)
|
|
280 |
{
|
|
281 |
// TODO: 在此添加命令更新用户界面处理程序代码
|
|
282 |
}
|
|
283 |
|
|
284 |
|
|
285 |
void CMainFrame::OnViewNumkeyBar()
|
|
286 |
{
|
|
287 |
// TODO: 在此添加命令处理程序代码
|
|
288 |
}
|
|
289 |
|
|
290 |
|
|
291 |
void CMainFrame::OnUpdateViewNumkeyBar(CCmdUI *pCmdUI)
|
|
292 |
{
|
|
293 |
// TODO: 在此添加命令更新用户界面处理程序代码
|
|
294 |
}
|
|
295 |
|
|
296 |
|
|
297 |
void CMainFrame::OnViewInputsegBar()
|
|
298 |
{
|
|
299 |
// TODO: 在此添加命令处理程序代码
|
|
300 |
}
|
|
301 |
|
|
302 |
|
|
303 |
void CMainFrame::OnUpdateViewInputsegBar(CCmdUI *pCmdUI)
|
|
304 |
{
|
|
305 |
// TODO: 在此添加命令更新用户界面处理程序代码
|
|
306 |
}
|
|
307 |
|
|
308 |
|
|
309 |
void CMainFrame::OnViewCommentsBar()
|
|
310 |
{
|
|
311 |
// TODO: 在此添加命令处理程序代码
|
|
312 |
}
|
|
313 |
|
|
314 |
|
|
315 |
void CMainFrame::OnUpdateViewCommentsBar(CCmdUI *pCmdUI)
|
|
316 |
{
|
|
317 |
// TODO: 在此添加命令更新用户界面处理程序代码
|
|
318 |
}
|
|
319 |
/*
|
|
320 |
CView * FindView(CDocument * pDoc, CRuntimeClass * pClass)
|
|
321 |
{
|
|
322 |
CView* pView = NULL;
|
|
323 |
POSITION pos = pDoc->GetFirstViewPosition();
|
|
324 |
while (pos != NULL)
|
|
325 |
{
|
|
326 |
pView = pDoc->GetNextView(pos);
|
|
327 |
if (pView->IsKindOf(pClass))
|
|
328 |
break;
|
|
329 |
}
|
|
330 |
if (!pView->IsKindOf(pClass))
|
|
331 |
{
|
|
332 |
//AfxMessageBox("Connt Locate the View.");
|
|
333 |
return NULL;
|
|
334 |
}
|
|
335 |
return pView;
|
|
336 |
}
|
|
337 |
*/
|
|
338 |
|