// MTerm1CtrlView.cpp: 实现文件 // #include "pch.h" #include "MTerm1.h" #include "MTerm1CtrlView.h" #include "MTerm1Doc.h" #include "ChildFrm.h" #include "../MyLib/Functions.hpp" // CMTerm1CtrlView IMPLEMENT_DYNCREATE(CMTerm1CtrlView, CFormView) CMTerm1CtrlView::CMTerm1CtrlView() : CFormView(IDD_MTerm1CtrlView) { } CMTerm1CtrlView::~CMTerm1CtrlView() { } void CMTerm1CtrlView::DoDataExchange(CDataExchange* pDX) { CFormView::DoDataExchange(pDX); } BEGIN_MESSAGE_MAP(CMTerm1CtrlView, CFormView) ON_BN_CLICKED(IDC_BUTTON_LOAD, &CMTerm1CtrlView::OnBnClickedButtonLoad) ON_BN_CLICKED(IDC_BUTTON_SAVE, &CMTerm1CtrlView::OnBnClickedButtonSave) ON_BN_CLICKED(ID_PROG_CONVERT, &CMTerm1CtrlView::OnBnClickedButtonConvert) ON_BN_CLICKED(IDC_BUTTON_CONVERT, &CMTerm1CtrlView::OnBnClickedButtonConvert) ON_BN_CLICKED(IDC_BUTTON_TRNS_TOTXT, &CMTerm1CtrlView::OnBnClickedButtonTrnsTotxt) ON_BN_CLICKED(IDC_BUTTON_TRNS_PRG, &CMTerm1CtrlView::OnBnClickedButtonTrnsPrg) ON_BN_CLICKED(IDC_BUTTON4, &CMTerm1CtrlView::OnBnClickedButton4) END_MESSAGE_MAP() // CMTerm1CtrlView 诊断 #ifdef _DEBUG void CMTerm1CtrlView::AssertValid() const { CFormView::AssertValid(); } #ifndef _WIN32_WCE void CMTerm1CtrlView::Dump(CDumpContext& dc) const { CFormView::Dump(dc); } #endif #endif //_DEBUG // CMTerm1CtrlView 消息处理程序 void CMTerm1CtrlView::OnInitialUpdate() { CFormView::OnInitialUpdate(); // TODO: 在此添加专用代码和/或调用基类 m_pStatusBar = ((CChildFrame *)GetParentFrame())->GetStatusBar(); ResizeParentToFit(); CMTerm1Doc * pDoc = (CMTerm1Doc *)GetDocument(); this->GetParentFrame()->SetWindowText(pDoc->GetTitle()); CString s1; CStringA s1A; pDoc->TransToTxt(s1A); s1 = s1A; SetDlgItemText(IDC_EDIT1, s1); } void CMTerm1CtrlView::OnUpdate(CView* /*pSender*/, LPARAM lHint, CObject* /*pHint*/) { // TODO: 在此添加专用代码和/或调用基类 CMTerm1Doc * pDoc = (CMTerm1Doc *)GetDocument(); CStringA s1A; pDoc->TransToTxt(s1A); CString s1; s1 = s1A; SetDlgItemText(IDC_EDIT1, s1); ((CEdit *)GetDlgItem(IDC_EDIT1))->SetSel((int)lHint, (int)lHint + 1); } void CMTerm1CtrlView::OnBnClickedButtonLoad() { // TODO: 在此添加控件通知处理程序代码 CMTerm1Doc * pDoc = (CMTerm1Doc *)GetDocument(); CFileDialog dialog1(true); INT_PTR r = dialog1.DoModal(); if (r == IDOK) { CString sFilePathName=dialog1.GetFileName(); pDoc->LoadFromFile(sFilePathName); // pDoc->UpdateAllViews(NULL); } } void CMTerm1CtrlView::OnBnClickedButtonSave() { // TODO: 在此添加控件通知处理程序代码 CString s1; CMTerm1Doc * pDoc = (CMTerm1Doc *)GetDocument(); // pDoc->DoFileSave(); } void CMTerm1CtrlView::OnBnClickedButtonConvert() { // TODO: 在此添加控件通知处理程序代码 CMTerm1Doc * pDoc = (CMTerm1Doc *)GetDocument(); CString s1; CStringA s1A; GetDlgItemText(IDC_EDIT1, s1); s1A = s1; pDoc->TransTxtToProg(s1A); pDoc->TransToTxt(s1A); s1 = s1A; SetDlgItemText(IDC_EDIT1, s1); pDoc->UpdateAllViews(this); } void CMTerm1CtrlView::OnBnClickedButtonTrnsTotxt() { // TODO: 在此添加控件通知处理程序代码 CMTerm1Doc * pDoc = (CMTerm1Doc *)GetDocument(); CStringA s1A; pDoc->TransToTxt(s1A); CString s1; s1 = s1A; // AnsiToT(s1A, s1); SetDlgItemText(IDC_EDIT1, s1); } void CMTerm1CtrlView::OnBnClickedButtonTrnsPrg() { // TODO: 在此添加控件通知处理程序代码 CMTerm1Doc * pDoc = (CMTerm1Doc *)GetDocument(); CString s1; CStringA s1A; GetDlgItemText(IDC_EDIT1, s1); s1A = s1; pDoc->TransFileToProg(s1A); pDoc->UpdateAllViews(this); // AnsiToT(s1A, s1); } void CMTerm1CtrlView::OnBnClickedButton4() { // TODO: 在此添加控件通知处理程序代码 CMTerm1Doc * pDoc = (CMTerm1Doc *)GetDocument(); pDoc->MyKLink1.fnTest1(2); CRect rect1; this->GetClientRect(&rect1); // this->GetParentFrame()->SetWindowPos(NULL, rect1.left, rect1.top, 100, 200, SWP_NOZORDER); }