// CMTerm1BnlView.cpp: 实现文件 // #include "pch.h" #include "MTerm1.h" #include "MTerm1BnlView.h" #include "MTerm1Doc.h" #include "ChildFrm.h" // CMTerm1BnlView IMPLEMENT_DYNCREATE(CMTerm1BnlView, CFormView) CMTerm1BnlView::CMTerm1BnlView() : CFormView(IDD_MTerm1BnlView) { } CMTerm1BnlView::~CMTerm1BnlView() { } void CMTerm1BnlView::DoDataExchange(CDataExchange* pDX) { CFormView::DoDataExchange(pDX); } BEGIN_MESSAGE_MAP(CMTerm1BnlView, CFormView) ON_BN_CLICKED(IDC_BUTTON_LOAD, &CMTerm1BnlView::OnBnClickedButtonLoad) ON_BN_CLICKED(IDC_BUTTON_SAVE, &CMTerm1BnlView::OnBnClickedButtonSave) ON_BN_CLICKED(ID_PROG_CONVERT, &CMTerm1BnlView::OnBnClickedButtonConvert) ON_BN_CLICKED(IDC_BUTTON_CONVERT, &CMTerm1BnlView::OnBnClickedButtonConvert) ON_BN_CLICKED(IDC_BUTTON_TRNS_TOTXT, &CMTerm1BnlView::OnBnClickedButtonTrnsTotxt) ON_BN_CLICKED(IDC_BUTTON_TRNS_PRG, &CMTerm1BnlView::OnBnClickedButtonTrnsPrg) ON_BN_CLICKED(IDC_BUTTON4, &CMTerm1BnlView::OnBnClickedButton4) ON_WM_SIZE() END_MESSAGE_MAP() // CMTerm1BnlView 诊断 #ifdef _DEBUG void CMTerm1BnlView::AssertValid() const { CFormView::AssertValid(); } #ifndef _WIN32_WCE void CMTerm1BnlView::Dump(CDumpContext& dc) const { CFormView::Dump(dc); } #endif #endif //_DEBUG // CMTerm1BnlView 绘图 void CMTerm1BnlView::OnDraw(CDC* pDC) { CDocument* pDoc = GetDocument(); // TODO: 在此添加绘制代码 } // CMTerm1BnlView 消息处理程序 void CMTerm1BnlView::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 CMTerm1BnlView::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 CMTerm1BnlView::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 CMTerm1BnlView::OnBnClickedButtonSave() { // TODO: 在此添加控件通知处理程序代码 CString s1; CMTerm1Doc* pDoc = (CMTerm1Doc*)GetDocument(); // pDoc->DoFileSave(); } void CMTerm1BnlView::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 CMTerm1BnlView::OnBnClickedButtonTrnsTotxt() { // TODO: 在此添加控件通知处理程序代码 CMTerm1Doc* pDoc = (CMTerm1Doc*)GetDocument(); CStringA s1A; pDoc->TransToTxt(s1A); CString s1; s1 = s1A; // AnsiToT(s1A, s1); SetDlgItemText(IDC_EDIT1, s1); } void CMTerm1BnlView::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 CMTerm1BnlView::OnBnClickedButton4() { // TODO: 在此添加控件通知处理程序代码 CMTerm1Doc* pDoc = (CMTerm1Doc*)GetDocument(); theApp.MyKLink1.fnTest1(2); CRect rect1; this->GetClientRect(&rect1); // this->GetParentFrame()->SetWindowPos(NULL, rect1.left, rect1.top, 100, 200, SWP_NOZORDER); } void CMTerm1BnlView::OnSize(UINT nType, int cx, int cy) { CFormView::OnSize(nType, cx, cy); CString s1; CWnd* pwnd; ///* pwnd = GetDlgItem(IDC_EDIT1); if (pwnd != NULL) { CRect rect1; pwnd->GetWindowRect(rect1); ScreenToClient(rect1); pwnd->SetWindowPos(NULL, 0, 0, rect1.Width(), cy - 20, NULL); // s1.Format(_T("OnSize %d %d %d \r\n"), nType, cx, cy); //((CEdit*)GetDlgItem(IDC_EDIT1))->ReplaceSel(s1); } // */ // // TODO: 在此处添加消息处理程序代码 }