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