|
// MainFrm.cpp: CMainFrame 类的实现
|
//
|
|
#include "pch.h"
|
#include "framework.h"
|
#include "MTerm1.h"
|
#include "MainFrm.h"
|
#include "ChildFrm.h"
|
|
#include "MTerm1Doc.h"
|
#include "MTerm1View.h"
|
#include "MTerm1CtrlView.h"
|
#include "MTerm1TestView.h"
|
#include "MTerm1ProgTxt.h"
|
#include <windows.h>
|
|
#ifdef _DEBUG
|
#define new DEBUG_NEW
|
#endif
|
|
// CMainFrame
|
|
|
IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWndEx)
|
|
BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWndEx)
|
ON_WM_CREATE()
|
ON_COMMAND(ID_UPLOAD_FROM_PLC, &CMainFrame::OnUploadFromPlc)
|
ON_COMMAND(ID_VIEW_FUNCKEY_BAR, &CMainFrame::OnViewFunckeyBar)
|
ON_UPDATE_COMMAND_UI(ID_VIEW_FUNCKEY_BAR, &CMainFrame::OnUpdateViewFunckeyBar)
|
ON_COMMAND(ID_VIEW_INPUT_BAR, &CMainFrame::OnViewInputBar)
|
ON_UPDATE_COMMAND_UI(ID_VIEW_INPUT_BAR, &CMainFrame::OnUpdateViewInputBar)
|
ON_COMMAND(ID_VIEW_NUMKEY_BAR, &CMainFrame::OnViewNumkeyBar)
|
ON_UPDATE_COMMAND_UI(ID_VIEW_NUMKEY_BAR, &CMainFrame::OnUpdateViewNumkeyBar)
|
ON_COMMAND(ID_VIEW_INPUTSEG_BAR, &CMainFrame::OnViewInputsegBar)
|
ON_UPDATE_COMMAND_UI(ID_VIEW_INPUTSEG_BAR, &CMainFrame::OnUpdateViewInputsegBar)
|
ON_COMMAND(ID_VIEW_COMMENTS_BAR, &CMainFrame::OnViewCommentsBar)
|
ON_UPDATE_COMMAND_UI(ID_VIEW_COMMENTS_BAR, &CMainFrame::OnUpdateViewCommentsBar)
|
|
// ON_COMMAND(ID_MENU_VIEW_LDS, &CMainFrame::OnMenuViewLds)
|
// ON_COMMAND(ID_MENU_VIEW_BLD, &CMainFrame::OnMenuViewBld)
|
// ON_COMMAND(ID_MENU_VIEW_BNL, &CMainFrame::OnMenuViewBnl)
|
|
ON_COMMAND(ID_MENU_SHOW_LOG, &CMainFrame::OnMenuShowLog)
|
ON_COMMAND(ID_MENU_SHOW_DEV, &CMainFrame::OnMenuShowDev)
|
ON_COMMAND(ID_MENU_SHOWNAV, &CMainFrame::OnMenuShownav)
|
END_MESSAGE_MAP()
|
|
static UINT indicators[] =
|
{
|
ID_SEPARATOR, // 状态行指示器
|
ID_INDICATOR_SEL_TYPE,
|
ID_INDICATOR_CAPS,
|
ID_INDICATOR_NUM,
|
ID_INDICATOR_SCRL,
|
};
|
|
// CMainFrame 构造/析构
|
|
CMainFrame::CMainFrame() noexcept
|
{
|
// TODO: 在此添加成员初始化代码
|
}
|
|
CMainFrame::~CMainFrame()
|
{
|
}
|
|
BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
|
{
|
// TODO: 在此添加专用代码和/或调用基类
|
// if (m_wndDlgBar_Func_Key.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo)) return TRUE;
|
|
return CMDIFrameWndEx::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
|
}
|
|
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
|
{
|
if (CMDIFrameWndEx::OnCreate(lpCreateStruct) == -1)
|
return -1;
|
// m_dlgMyLog.Create(m_dlgMyLog.IDD, GetParent());
|
// m_dlgMyLog.ShowWindow(SW_SHOW);
|
|
// BOOL bNameValid;
|
|
// 创建类视图
|
CString strNavView;
|
// bNameValid = strNavView.LoadString(IDS_CLASS_VIEW);
|
// ASSERT(bNameValid);
|
///*
|
strNavView = _T("导航视图");
|
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))
|
{
|
TRACE0("未能创建“导航视图”窗口\n");
|
return FALSE; // 未能创建
|
}
|
m_wndNavView.EnableDocking(CBRS_ALIGN_LEFT);
|
DockPane(&m_wndNavView);
|
//DockControlBar(&m_wndNavView);
|
//*/
|
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
|
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
|
{
|
TRACE0("未能创建工具栏\n");
|
return -1; // 未能创建
|
}
|
|
/* 输入栏
|
if (!m_wndTBar_InputShow.CreateEx(this, TBSTYLE_FLAT,
|
WS_CHILD | WS_VISIBLE | CBRS_BOTTOM | CBRS_FLOAT_MULTI | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC,
|
CRect(1, 1, 1, 1), IDW_TOOL_BAR2) ||
|
!m_wndTBar_InputShow.LoadToolBar(IDR_TOOLBAR_INPUT_SHOW))
|
{
|
TRACE0("未能创建数字工具栏\n");
|
return -1; // 未能创建
|
}
|
CRect rect1;
|
int index = m_wndTBar_InputShow.CommandToIndex(ID_BUTTON_INPUT_SHOW);
|
UINT nID,nStyle;
|
int iImage;
|
m_wndTBar_InputShow.GetButtonInfo(0, nID, nStyle, iImage);
|
m_wndTBar_InputShow.SetButtonInfo(index, ID_BUTTON_INPUT_SHOW, TBBS_SEPARATOR, 100);
|
m_wndTBar_InputShow.GetItemRect(index, &rect1);
|
rect1.left = 1;
|
rect1.top = 2;
|
rect1.right = rect1.left + 100;
|
rect1.bottom = rect1.top + 20;
|
//*/
|
/*
|
if (!m_InputShowEdit.Create(WS_CHILD | WS_VISIBLE | WS_BORDER, rect1, \
|
&m_wndTBar_InputShow, ID_BUTTON_INPUT_SHOW))
|
{
|
TRACE(_T("Failed to create CEdit\n"));
|
return FALSE;
|
}
|
|
if (!m_InputShowStatic.Create(_T("Test1"),WS_CHILD | WS_VISIBLE |WS_EX_CLIENTEDGE, rect1, \
|
&m_wndTBar_InputShow, ID_BUTTON_INPUT_SHOW))
|
{
|
TRACE(_T("Failed to create CStaticEx\n"));
|
return FALSE;
|
}
|
m_InputShowStatic.SetBkColor(RGB(255, 255, 255));
|
m_InputShowStatic.SetTextColor(RGB(255, 128, 128));
|
m_InputShowStatic.SetTextSize(20);
|
//*/
|
//m_InputShowEdit.SetReadOnly(true);
|
/*
|
if (!m_wndTBar_Num_Key.CreateEx(this, TBSTYLE_FLAT,
|
WS_CHILD | WS_VISIBLE | CBRS_BOTTOM | CBRS_FLOAT_MULTI | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC,
|
CRect(1,1,1,1),IDW_TOOL_BAR2) ||
|
!m_wndTBar_Num_Key.LoadToolBar(IDR_TOOLBAR_NUM_KEY))
|
{
|
TRACE0("未能创建数字键工具栏\n");
|
return -1; // 未能创建
|
}
|
//*/
|
|
/*
|
if (!m_wndTBar_Edit_Key.CreateEx(this, TBSTYLE_FLAT,
|
WS_CHILD | WS_VISIBLE | CBRS_BOTTOM | CBRS_FLOAT_MULTI | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC,
|
CRect(1, 1, 1, 1), IDR_TOOLBAR_EDIT_KEY) ||
|
!m_wndTBar_Edit_Key.LoadToolBar(IDR_TOOLBAR_EDIT_KEY))
|
{
|
TRACE0("未能创建编辑键工具栏\n");
|
return -1; // 未能创建
|
}
|
//*/
|
/*
|
if (!m_wndToolBar_Func_Key.CreateEx(this, TBSTYLE_FLAT,
|
WS_CHILD | WS_VISIBLE | CBRS_BOTTOM | CBRS_FLOAT_MULTI | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC,
|
CRect(1, 1, 1, 1), IDW_TOOL_BAR_FUNC_KEY) ||
|
!m_wndToolBar_Func_Key.LoadToolBar(IDR_TOOLBAR_FUNC_KEY2))
|
{
|
TRACE0("未能创建功能键工具栏\n");
|
return -1; // 未能创建
|
}
|
//m_wndToolBar_Func_Key.SetTwoRowsWithSibling();
|
//*/
|
/*
|
if (!m_wndDlgBar_InputShow.Create(this, IDD_DIALOGBAR_INPUT_SHOW, WS_CHILD | WS_VISIBLE | CBRS_BOTTOM | CBRS_FLOAT_MULTI | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC,
|
IDD_DIALOGBAR_INPUT_SHOW))
|
{
|
TRACE0("未能创建功能键2工具栏\n");
|
return -1; // 未能创建
|
}
|
//*/
|
/*
|
if (!m_wndDlgBar_Func_Key.Create(this, IDD_DIALOGBAR_FUNC_KEYS,WS_CHILD | WS_VISIBLE | CBRS_BOTTOM | CBRS_FLOAT_MULTI | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC,
|
IDD_DIALOGBAR_FUNC_KEYS))
|
{
|
TRACE0("未能创建功能键2工具栏\n");
|
return -1; // 未能创建
|
}
|
// ShowControlBar(&m_wndDlgBar_Func_Key, TRUE, TRUE);
|
// m_wndDlgBar_Func_Key.MoveWindow(100, 100, 200, 200);
|
//*/
|
|
if (!m_wndStatusBar.Create(this))
|
{
|
TRACE0("未能创建状态栏\n");
|
return -1; // 未能创建
|
}
|
m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT));
|
m_wndStatusBar.SetPaneStyle(0, SBPS_STRETCH);
|
//m_wndStatusBar.OnCtlColor();
|
///*
|
if (!m_wndMyPaneLog.Create(_T("日志窗口"), this, CRect(0, 0, 200, 200), TRUE, 1235, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS
|
| WS_CLIPCHILDREN | CBRS_RIGHT | CBRS_FLOAT_MULTI))
|
{
|
TRACE0("未能创建“MyPaneLog窗口\n");
|
return FALSE;
|
}
|
m_wndMyPaneLog.EnableDocking(CBRS_ALIGN_ANY);
|
//*/
|
// //
|
///*
|
|
if (!m_wndMyPaneInputShow.Create(_T("输入窗口"), this, CRect(2, 2, 20, 20), TRUE, 1236, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS
|
| WS_CLIPCHILDREN | CBRS_BOTTOM | CBRS_FLOAT_MULTI))
|
{
|
TRACE0("未能创建“MyPaneInputShow窗口\n");
|
return FALSE;
|
}
|
m_wndMyPaneInputShow.EnableDocking(CBRS_ALIGN_BOTTOM);
|
|
//*/
|
// m_dlgMyLog.Create(m_dlgMyLog.IDD, this);
|
// m_dlgMyLog.ModifyStyle(0, WS_POPUPWINDOW);
|
// m_dlgMyLog.ShowWindow(SW_SHOW);
|
|
// TODO: 如果不需要可停靠工具栏,则删除这三行
|
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
|
EnableDocking(CBRS_ALIGN_ANY);
|
DockPane(&m_wndToolBar);
|
// DockControlBar(&m_wndToolBar);
|
|
// EnableDocking(CBRS_ALIGN_ANY);
|
|
|
|
// CDockablePane* pTabbedBar = nullptr;
|
// m_wndNavView.AttachToTabWnd(&m_wndFileView, DM_SHOW, TRUE, &pTabbedBar);
|
|
|
///*
|
// m_wndDlgBar_InputShow.EnableDocking(CBRS_ALIGN_TOP | CBRS_ALIGN_BOTTOM);
|
// m_wndTBar_Num_Key.EnableDocking(CBRS_ALIGN_ANY);
|
// m_wndTBar_Edit_Key.EnableDocking(CBRS_ALIGN_ANY);
|
// m_wndToolBar_Func_Key.EnableDocking(CBRS_ALIGN_ANY);
|
// m_wndDlgBar_Func_Key.EnableDocking(CBRS_ALIGN_TOP| CBRS_ALIGN_BOTTOM);
|
|
// EnableDocking(CBRS_ALIGN_ANY);
|
|
// DockPane(&m_wndToolBar);
|
|
// DockControlBar(&m_wndDlgBar_InputShow);
|
// DockControlBar(&m_wndTBar_Num_Key);
|
// DockControlBar(&m_wndTBar_Edit_Key);
|
// DockPane(&m_wndToolBar_Func_Key);
|
// DockPane(&m_wndDlgBar_Func_Key);
|
// DockControlBar(&m_wndDlgBar_Func_Key);
|
DockPane(&m_wndMyPaneInputShow);
|
DockPane(&m_wndNavView);
|
DockPane(&m_wndMyPaneLog);
|
|
// m_wndMyPaneInputShow.m_pMyFormInputShow->SetBtnDisplayESC(1);
|
|
//*/
|
return 0;
|
}
|
|
|
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
|
{
|
if( !CMDIFrameWndEx::PreCreateWindow(cs) )
|
return FALSE;
|
// TODO: 在此处通过修改
|
// CREATESTRUCT cs 来修改窗口类或样式
|
|
return TRUE;
|
}
|
|
// CMainFrame 诊断
|
|
#ifdef _DEBUG
|
void CMainFrame::AssertValid() const
|
{
|
CMDIFrameWndEx::AssertValid();
|
}
|
|
void CMainFrame::Dump(CDumpContext& dc) const
|
{
|
CMDIFrameWndEx::Dump(dc);
|
}
|
#endif //_DEBUG
|
|
|
// CMainFrame 消息处理程序
|
|
|
|
void CMainFrame::OnUploadFromPlc()
|
{
|
// TODO: 在此添加命令处理程序代码
|
SysLog(_T("Upload from PLC, (From mainframe)"));
|
CWinAppEx* pApp = &theApp;
|
|
POSITION curTemplatePos = theApp.m_pDocManager->GetFirstDocTemplatePosition();
|
if (curTemplatePos != NULL)
|
{
|
CDocTemplate* curTemplate = theApp.m_pDocManager->GetNextDocTemplate(curTemplatePos);
|
CMTerm1Doc* pDoc = (CMTerm1Doc* ) curTemplate->OpenDocumentFile(NULL);
|
if (pDoc) pDoc->OnUploadFromPlc();
|
}
|
|
}
|
|
void CMainFrame::OnMenuShowLog()
|
{
|
// TODO: 在此添加命令处理程序代码
|
m_wndMyPaneLog.ShowWindow(SW_SHOW);
|
// m_wndNavView.ShowWindow(SW_SHOW);
|
}
|
|
|
void CMainFrame::OnViewFunckeyBar()
|
{
|
// TODO: 在此添加命令处理程序代码
|
CString s1;
|
s1.Format(_T("显示功能键栏"));
|
SysLog(s1);
|
// m_wndDlgBar_Func_Key.ShowWindow(SW_HIDE);
|
// m_wndDlgBar_Func_Key.ShowWindow(SW_SHOW);
|
// ShowControlBar(&m_wndDlgBar_Func_Key, TRUE, FALSE);
|
|
}
|
|
|
void CMainFrame::OnUpdateViewFunckeyBar(CCmdUI *pCmdUI)
|
{
|
// TODO: 在此添加命令更新用户界面处理程序代码
|
|
}
|
|
|
void CMainFrame::OnViewInputBar()
|
{
|
// TODO: 在此添加命令处理程序代码
|
}
|
|
|
void CMainFrame::OnUpdateViewInputBar(CCmdUI *pCmdUI)
|
{
|
// TODO: 在此添加命令更新用户界面处理程序代码
|
}
|
|
|
void CMainFrame::OnViewNumkeyBar()
|
{
|
// TODO: 在此添加命令处理程序代码
|
CString s1;
|
s1.Format(_T("显示数字键栏"));
|
SysLog(s1);
|
// m_wndTBar_Num_Key.ShowWindow(SW_HIDE);
|
// m_wndTBar_Num_Key.ShowWindow(SW_SHOW);
|
|
}
|
|
|
void CMainFrame::OnUpdateViewNumkeyBar(CCmdUI *pCmdUI)
|
{
|
// TODO: 在此添加命令更新用户界面处理程序代码
|
}
|
|
|
void CMainFrame::OnViewInputsegBar()
|
{
|
// TODO: 在此添加命令处理程序代码
|
}
|
|
|
void CMainFrame::OnUpdateViewInputsegBar(CCmdUI *pCmdUI)
|
{
|
// TODO: 在此添加命令更新用户界面处理程序代码
|
}
|
|
|
void CMainFrame::OnViewCommentsBar()
|
{
|
// TODO: 在此添加命令处理程序代码
|
}
|
|
|
void CMainFrame::OnUpdateViewCommentsBar(CCmdUI *pCmdUI)
|
{
|
// TODO: 在此添加命令更新用户界面处理程序代码
|
}
|
/*
|
CView * FindView(CDocument * pDoc, CRuntimeClass * pClass)
|
{
|
CView* pView = NULL;
|
POSITION pos = pDoc->GetFirstViewPosition();
|
while (pos != NULL)
|
{
|
pView = pDoc->GetNextView(pos);
|
if (pView->IsKindOf(pClass))
|
break;
|
}
|
if (!pView->IsKindOf(pClass))
|
{
|
//AfxMessageBox("Connt Locate the View.");
|
return NULL;
|
}
|
return pView;
|
}
|
*/
|
|
int CMainFrame::GetInputInfo(int inputInfo)
|
{
|
// TODO: 在此处添加实现代码.
|
CString m_InputInfo;
|
|
CString s1;
|
s1.Format(_T("From MainFrame , input %s"), m_InputInfo);
|
SysLog(s1);
|
|
// m_wndDlgBar_InputShow.SetDisplay(inputInfo);
|
|
return 0;
|
}
|
|
int CMainFrame::SetDisplayInfo(int Info)
|
{
|
// TODO: 在此处添加实现代码.
|
CString m_InputInfo;
|
|
CString s1;
|
s1.Format(_T("From MainFrame , SetDisplayInfo %x"), Info);
|
SysLog(s1);
|
|
// m_wndDlgBar_InputShow.SetDisplay(inputInfo);
|
m_wndMyPaneInputShow.m_pMyFormInputShow->SetDisplay(Info);
|
return 0;
|
}
|
|
int CMainFrame::SetCellInfo(int info)
|
{
|
// TODO: 在此处添加实现代码.
|
CString m_InputInfo;
|
|
CString s1;
|
s1.Format(_T("From MainFrame , SetCellInfo %x"), info);
|
SysLog(s1);
|
|
// m_wndDlgBar_InputShow.SetDisplay(inputInfo);
|
|
return 0;
|
}
|
|
int CMainFrame::GetInputCell(tagInputCell inputCell)
|
{
|
|
// localInputCell = inputCell;
|
return 0;
|
}
|
|
void CMainFrame::OnMenuShowDev()
|
{
|
// TODO: 在此添加命令处理程序代码
|
|
}
|
|
void CMainFrame::OnMenuShownav()
|
{
|
// TODO: 在此添加命令处理程序代码
|
m_wndNavView.ShowWindow(SW_SHOW);
|
}
|