QuakeGod
2024-12-24 61deef5cdf96cbfdd6ad45be49e80d597c00ca65
提交 | 用户 | 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)
61deef 37     ON_WM_SIZE()
418cb3 38 END_MESSAGE_MAP()
Q 39
40
41 // CMTerm1CtrlView 诊断
42
43 #ifdef _DEBUG
44 void CMTerm1CtrlView::AssertValid() const
45 {
46     CFormView::AssertValid();
47 }
48
49 #ifndef _WIN32_WCE
50 void CMTerm1CtrlView::Dump(CDumpContext& dc) const
51 {
52     CFormView::Dump(dc);
53 }
54 #endif
55 #endif //_DEBUG
56
57
58 // CMTerm1CtrlView 消息处理程序
59
60 void CMTerm1CtrlView::OnInitialUpdate()
61 {
62     CFormView::OnInitialUpdate();
63     // TODO: 在此添加专用代码和/或调用基类
64     m_pStatusBar = ((CChildFrame *)GetParentFrame())->GetStatusBar();
65     ResizeParentToFit();
66     CMTerm1Doc * pDoc = (CMTerm1Doc *)GetDocument();
67     this->GetParentFrame()->SetWindowText(pDoc->GetTitle());
68     CString s1;
69     CStringA s1A;
70     pDoc->TransToTxt(s1A);
71     s1 = s1A;
72     SetDlgItemText(IDC_EDIT1, s1);
73
74
75 }
76
77
78 void CMTerm1CtrlView::OnUpdate(CView* /*pSender*/, LPARAM lHint, CObject* /*pHint*/)
79 {
80     // TODO: 在此添加专用代码和/或调用基类
81     CMTerm1Doc * pDoc = (CMTerm1Doc *)GetDocument();
82     CStringA s1A;
83     pDoc->TransToTxt(s1A);
84     CString s1;
85     s1 = s1A;
86     SetDlgItemText(IDC_EDIT1, s1);
87     ((CEdit *)GetDlgItem(IDC_EDIT1))->SetSel((int)lHint, (int)lHint + 1);
88 }
89
90
91 void CMTerm1CtrlView::OnBnClickedButtonLoad()
92 {
93     // TODO: 在此添加控件通知处理程序代码
94     CMTerm1Doc * pDoc = (CMTerm1Doc *)GetDocument();
95     CFileDialog dialog1(true);
96     INT_PTR r = dialog1.DoModal();
97     if (r == IDOK)
98     {
99         CString sFilePathName=dialog1.GetFileName();
100         pDoc->LoadFromFile(sFilePathName);
101 //        pDoc->UpdateAllViews(NULL);
102     }
103 }
104
105
106 void CMTerm1CtrlView::OnBnClickedButtonSave()
107 {
108     // TODO: 在此添加控件通知处理程序代码
109     CString s1;
110     CMTerm1Doc * pDoc = (CMTerm1Doc *)GetDocument();
111 //    pDoc->DoFileSave();
112 }
113
114
115 void CMTerm1CtrlView::OnBnClickedButtonConvert()
116 {
117     // TODO: 在此添加控件通知处理程序代码
118     CMTerm1Doc * pDoc = (CMTerm1Doc *)GetDocument();
119     CString s1;
120     CStringA s1A;
121     GetDlgItemText(IDC_EDIT1, s1);
122     s1A = s1;
123     pDoc->TransTxtToProg(s1A);
124     pDoc->TransToTxt(s1A);
125     s1 = s1A;
126     SetDlgItemText(IDC_EDIT1, s1);
127     pDoc->UpdateAllViews(this);
128 }
129
130
131 void CMTerm1CtrlView::OnBnClickedButtonTrnsTotxt()
132 {
133     // TODO: 在此添加控件通知处理程序代码
134     CMTerm1Doc * pDoc = (CMTerm1Doc *)GetDocument();
135     CStringA s1A;
136     pDoc->TransToTxt(s1A);
137     CString s1;
138     s1 = s1A;
139 //    AnsiToT(s1A, s1);
140     SetDlgItemText(IDC_EDIT1, s1);
141
142 }
143
144
145 void CMTerm1CtrlView::OnBnClickedButtonTrnsPrg()
146 {
147     // TODO: 在此添加控件通知处理程序代码
148     CMTerm1Doc * pDoc = (CMTerm1Doc *)GetDocument();
149     CString s1;
150     CStringA s1A;
151     GetDlgItemText(IDC_EDIT1, s1);
152     s1A = s1;
153     pDoc->TransFileToProg(s1A);
154     pDoc->UpdateAllViews(this);
155     //    AnsiToT(s1A, s1);
156
157 }
158
159
160
161 void CMTerm1CtrlView::OnBnClickedButton4()
162 {
163     // TODO: 在此添加控件通知处理程序代码
164     CMTerm1Doc * pDoc = (CMTerm1Doc *)GetDocument();
61deef 165     theApp.MyKLink1.fnTest1(2);
418cb3 166
Q 167     CRect rect1;
168     this->GetClientRect(&rect1);
169 //    this->GetParentFrame()->SetWindowPos(NULL, rect1.left, rect1.top, 100, 200, SWP_NOZORDER);
170
171 }
61deef 172
Q 173
174 void CMTerm1CtrlView::OnSize(UINT nType, int cx, int cy)
175 {
176     CFormView::OnSize(nType, cx, cy);
177     CString s1;
178     CWnd* pwnd;
179     ///*
180     pwnd = GetDlgItem(IDC_EDIT1);
181     if (pwnd != NULL)
182     {
183         CRect    rect1;
184         pwnd->GetWindowRect(rect1);
185         ScreenToClient(rect1);
186
187         pwnd->SetWindowPos(NULL, 0, 0, rect1.Width(), cy - 20, NULL);
188         //        s1.Format(_T("OnSize %d  %d %d \r\n"), nType, cx, cy);
189         //((CEdit*)GetDlgItem(IDC_EDIT1))->ReplaceSel(s1);
190
191     }
192     // */
193     // 
194     // TODO: 在此处添加消息处理程序代码
195
196 }