QuakeGod
2023-09-05 df03213660361b1c771f0a3f21b6ddaeaef7763a
提交 | 用户 | age
418cb3 1 // MTerm1CtrlView.cpp: 实现文件
Q 2 //
3
4 #include "pch.h"
5 #include "MTerm1.h"
6 #include "MTerm1CtrlView.h"
7 #include "MTerm1Doc.h"
8 #include "ChildFrm.h"
9 #include "../MyLib/Functions.hpp"
10 // CMTerm1CtrlView
11
12 IMPLEMENT_DYNCREATE(CMTerm1CtrlView, CFormView)
13
14 CMTerm1CtrlView::CMTerm1CtrlView()
15     : CFormView(IDD_MTerm1CtrlView)
16 {
17
18 }
19
20 CMTerm1CtrlView::~CMTerm1CtrlView()
21 {
22 }
23
24 void CMTerm1CtrlView::DoDataExchange(CDataExchange* pDX)
25 {
26     CFormView::DoDataExchange(pDX);
27 }
28
29 BEGIN_MESSAGE_MAP(CMTerm1CtrlView, CFormView)
30     ON_BN_CLICKED(IDC_BUTTON_LOAD, &CMTerm1CtrlView::OnBnClickedButtonLoad)
31     ON_BN_CLICKED(IDC_BUTTON_SAVE, &CMTerm1CtrlView::OnBnClickedButtonSave)
32     ON_BN_CLICKED(ID_PROG_CONVERT, &CMTerm1CtrlView::OnBnClickedButtonConvert)
33     ON_BN_CLICKED(IDC_BUTTON_CONVERT, &CMTerm1CtrlView::OnBnClickedButtonConvert)
34     ON_BN_CLICKED(IDC_BUTTON_TRNS_TOTXT, &CMTerm1CtrlView::OnBnClickedButtonTrnsTotxt)
35     ON_BN_CLICKED(IDC_BUTTON_TRNS_PRG, &CMTerm1CtrlView::OnBnClickedButtonTrnsPrg)
36     ON_BN_CLICKED(IDC_BUTTON4, &CMTerm1CtrlView::OnBnClickedButton4)
37 END_MESSAGE_MAP()
38
39
40 // CMTerm1CtrlView 诊断
41
42 #ifdef _DEBUG
43 void CMTerm1CtrlView::AssertValid() const
44 {
45     CFormView::AssertValid();
46 }
47
48 #ifndef _WIN32_WCE
49 void CMTerm1CtrlView::Dump(CDumpContext& dc) const
50 {
51     CFormView::Dump(dc);
52 }
53 #endif
54 #endif //_DEBUG
55
56
57 // CMTerm1CtrlView 消息处理程序
58
59 void CMTerm1CtrlView::OnInitialUpdate()
60 {
61     CFormView::OnInitialUpdate();
62     // TODO: 在此添加专用代码和/或调用基类
63     m_pStatusBar = ((CChildFrame *)GetParentFrame())->GetStatusBar();
64     ResizeParentToFit();
65     CMTerm1Doc * pDoc = (CMTerm1Doc *)GetDocument();
66     this->GetParentFrame()->SetWindowText(pDoc->GetTitle());
67     CString s1;
68     CStringA s1A;
69     pDoc->TransToTxt(s1A);
70     s1 = s1A;
71     SetDlgItemText(IDC_EDIT1, s1);
72
73
74 }
75
76
77 void CMTerm1CtrlView::OnUpdate(CView* /*pSender*/, LPARAM lHint, CObject* /*pHint*/)
78 {
79     // TODO: 在此添加专用代码和/或调用基类
80     CMTerm1Doc * pDoc = (CMTerm1Doc *)GetDocument();
81     CStringA s1A;
82     pDoc->TransToTxt(s1A);
83     CString s1;
84     s1 = s1A;
85     SetDlgItemText(IDC_EDIT1, s1);
86     ((CEdit *)GetDlgItem(IDC_EDIT1))->SetSel((int)lHint, (int)lHint + 1);
87 }
88
89
90 void CMTerm1CtrlView::OnBnClickedButtonLoad()
91 {
92     // TODO: 在此添加控件通知处理程序代码
93     CMTerm1Doc * pDoc = (CMTerm1Doc *)GetDocument();
94     CFileDialog dialog1(true);
95     INT_PTR r = dialog1.DoModal();
96     if (r == IDOK)
97     {
98         CString sFilePathName=dialog1.GetFileName();
99         pDoc->LoadFromFile(sFilePathName);
100 //        pDoc->UpdateAllViews(NULL);
101     }
102 }
103
104
105 void CMTerm1CtrlView::OnBnClickedButtonSave()
106 {
107     // TODO: 在此添加控件通知处理程序代码
108     CString s1;
109     CMTerm1Doc * pDoc = (CMTerm1Doc *)GetDocument();
110 //    pDoc->DoFileSave();
111 }
112
113
114 void CMTerm1CtrlView::OnBnClickedButtonConvert()
115 {
116     // TODO: 在此添加控件通知处理程序代码
117     CMTerm1Doc * pDoc = (CMTerm1Doc *)GetDocument();
118     CString s1;
119     CStringA s1A;
120     GetDlgItemText(IDC_EDIT1, s1);
121     s1A = s1;
122     pDoc->TransTxtToProg(s1A);
123     pDoc->TransToTxt(s1A);
124     s1 = s1A;
125     SetDlgItemText(IDC_EDIT1, s1);
126     pDoc->UpdateAllViews(this);
127 }
128
129
130 void CMTerm1CtrlView::OnBnClickedButtonTrnsTotxt()
131 {
132     // TODO: 在此添加控件通知处理程序代码
133     CMTerm1Doc * pDoc = (CMTerm1Doc *)GetDocument();
134     CStringA s1A;
135     pDoc->TransToTxt(s1A);
136     CString s1;
137     s1 = s1A;
138 //    AnsiToT(s1A, s1);
139     SetDlgItemText(IDC_EDIT1, s1);
140
141 }
142
143
144 void CMTerm1CtrlView::OnBnClickedButtonTrnsPrg()
145 {
146     // TODO: 在此添加控件通知处理程序代码
147     CMTerm1Doc * pDoc = (CMTerm1Doc *)GetDocument();
148     CString s1;
149     CStringA s1A;
150     GetDlgItemText(IDC_EDIT1, s1);
151     s1A = s1;
152     pDoc->TransFileToProg(s1A);
153     pDoc->UpdateAllViews(this);
154     //    AnsiToT(s1A, s1);
155
156 }
157
158
159
160 void CMTerm1CtrlView::OnBnClickedButton4()
161 {
162     // TODO: 在此添加控件通知处理程序代码
163     CMTerm1Doc * pDoc = (CMTerm1Doc *)GetDocument();
164     pDoc->MyKLink1.fnTest1(2);
165
166     CRect rect1;
167     this->GetClientRect(&rect1);
168 //    this->GetParentFrame()->SetWindowPos(NULL, rect1.left, rect1.top, 100, 200, SWP_NOZORDER);
169
170 }