-
Notifications
You must be signed in to change notification settings - Fork 2
/
EditArea.cpp
371 lines (308 loc) · 8.63 KB
/
EditArea.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
// EditArea.cpp : implementation file
//
#include "stdafx.h"
#include "str.h"
#include "HustBaseDoc.h"
#include "MainFrm.h"
#include "HustBase.h"
#include "EditArea.h"
#include "HustBaseView.h"
#include "string.h"
#include "stdio.h"
#include "RM_Manager.h"
#include "SYS_Manager.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CEditArea
IMPLEMENT_DYNCREATE(CEditArea, CEditView)
CEditArea::CEditArea()
{
}
CEditArea::~CEditArea()
{
}
BEGIN_MESSAGE_MAP(CEditArea, CEditView)
//{{AFX_MSG_MAP(CEditArea)
ON_WM_CREATE()
ON_COMMAND(ID_RUN, OnRunBtn)
ON_UPDATE_COMMAND_UI(ID_RUN, OnUpdateRun)
ON_CONTROL_REFLECT(EN_CHANGE, OnChange)
ON_WM_SIZE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
int CEditArea::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (-1 == CEditView::OnCreate(lpCreateStruct))
{
return -1;
}
GetDocument()->m_pEditView = this;
return 0;
}
/////////////////////////////////////////////////////////////////////////////
// CEditArea drawing
void CEditArea::OnDraw(CDC* pDC)
{
CDocument* pDoc = GetDocument();
// TODO: add draw code here
}
/////////////////////////////////////////////////////////////////////////////
// CEditArea diagnostics
#ifdef _DEBUG
void CEditArea::AssertValid() const
{
CEditView::AssertValid();
}
void CEditArea::Dump(CDumpContext& dc) const
{
CEditView::Dump(dc);
}
CHustBaseDoc* CEditArea::GetDocument()
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CHustBaseDoc)));
return (CHustBaseDoc*)m_pDocument;
}
#endif //_DEBUG
void CEditArea::OnSize(UINT nType, int cx, int cy)
{
this->ShowWindow(SW_MAXIMIZE);
CWnd* pChild = this->GetWindow(GW_CHILD);
if (pChild != NULL)
{
CRect rect;
this->GetWindowRect(&rect);
pChild->ScreenToClient(&rect);
pChild->SetWindowPos(NULL, 0, 0, rect.Width(), rect.Height(),
SWP_NOACTIVATE | SWP_NOZORDER);
}
}
void CEditArea::OnChange()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CEditView::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
GetEditCtrl().SetModify(FALSE);
}
/////////////////////////////////////////////////////////////////////////////
// CEditArea message handlers
void CEditArea::OnRunBtn()
{
// TODO: Add your command handler code here
// HWND hWnd;
CHustBaseDoc* pDoc = (CHustBaseDoc*)GetDocument();
CString analyzeResult;
sqlstr* sql_str = NULL; //定义联合变量和FLAG的结构体对象
RC rc;
CMainFrame* main = (CMainFrame*)AfxGetApp()->m_pMainWnd;
CWnd* pPaneShow = (CWnd*)main->m_wmSplitter1.GetPane(0, 0);
pPaneShow->GetWindowText(pDoc->get_text);
char* str = (LPSTR)(LPCTSTR)pDoc->get_text;
pDoc->isEdit = false;
ExecuteAndMessage(str, this);//可以对此函数进行修改来设置页面展示的信息
pDoc = CHustBaseDoc::GetDoc();
CHustBaseApp::pathvalue = true;
pDoc->m_pTreeView->PopulateTree();
}
void CEditArea::OnInitialUpdate()
{
CEditView::OnInitialUpdate();
}
void CEditArea::OnUpdateRun(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
CString testText;
CMainFrame* main = (CMainFrame*)AfxGetApp()->m_pMainWnd;
CWnd* pPaneShow = main->m_wmSplitter1.GetPane(0, 0);
pPaneShow->GetWindowText(testText);
if (0 == testText.GetLength())
{
pCmdUI->Enable(FALSE);
}
else {
pCmdUI->Enable(CanButtonClick());
}
}
void CEditArea::displayInfo()
{
CHustBaseDoc* pDoc = (CHustBaseDoc*)GetDocument();
CMainFrame* main = (CMainFrame*)AfxGetApp()->m_pMainWnd; //获取窗口指针
CWnd* pPane = (CWnd*)main->m_wmSplitter1.GetPane(2, 0);
CClientDC dc(pPane);
CRect cr;
pPane->GetClientRect(cr);
COLORREF clr = dc.GetBkColor();
dc.FillSolidRect(cr, clr); //清空之前输出的文字;
CFont font;
font.CreatePointFont(118, "微软雅黑", NULL);//设置字体
CFont* pOldFont = dc.SelectObject(&font);
TEXTMETRIC tm;
dc.GetTextMetrics(&tm);
for (int i = 0; i < pDoc->infoCount; i++)
{
dc.TextOut(0, 20 * i, pDoc->Info[i]);
}
}
int CEditArea::iReadDictstruct(char tabname[][20], int* tabnum, char colname[][20][20], int colnum[], AttrType coltype[][20], int collength[][20], int coloffset[][20], int iscolindex[][20])//编写新的传递系统表和系统列信息的函数
{
CHustBaseDoc* pDoc = (CHustBaseDoc*)GetDocument();
RM_FileHandle fileHandle, colfilehandle;
fileHandle.bOpen = 0;
colfilehandle.bOpen = 0;
RM_FileScan FileScan1, FileScan2;
FileScan1.bOpen = 0;
FileScan2.bOpen = 0;
RM_Record rec1, rec2;
Con condition;
RC rc;
CString t;//test
int i = 0, j = 0;
DWORD cchCurDir = BUFFER;
LPTSTR lpszCurDir;
TCHAR tchBuffer[BUFFER];
lpszCurDir = tchBuffer;
GetCurrentDirectory(cchCurDir, lpszCurDir);
CString Path = lpszCurDir;
CString table = Path + "\\SYSTABLES.xx";
CString column = Path + "\\SYSCOLUMNS.xx";
rc = RM_OpenFile((LPSTR)(LPCTSTR)table, &fileHandle);//去SYSTABLES表中获取表名
if (rc != SUCCESS)
AfxMessageBox("打开系统表文件失败");
rc = RM_OpenFile((LPSTR)(LPCTSTR)column, &colfilehandle);//去SYSCOLUMNS表中获取列名
if (rc != SUCCESS)
AfxMessageBox("打开系统列文件失败");
rc = OpenScan(&FileScan1, &fileHandle, 0, NULL);
if (rc != SUCCESS)
AfxMessageBox("初始化表文件扫描失败");
rec1.pData = new char[SIZE_SYS_TABLE];
memset(rec1.pData, 0, SIZE_SYS_TABLE);
rec2.pData = new char[SIZE_SYS_COLUMNS];
memset(rec2.pData, 0, SIZE_SYS_COLUMNS);
while (GetNextRec(&FileScan1, &rec1) == SUCCESS)
{
strcpy(tabname[i], rec1.pData);
condition.bLhsIsAttr = 1;
condition.bRhsIsAttr = 0;
// condition.LattrLength=strlen(tabname[i])+1;
condition.LattrOffset = 0;
condition.attrType = chars;
condition.compOp = EQual;
condition.Rvalue = tabname[i];
rc = OpenScan(&FileScan2, &colfilehandle, 1, &condition);
if (rc != SUCCESS) {
AfxMessageBox("初始化列文件扫描失败");
}
while (GetNextRec(&FileScan2, &rec2) == SUCCESS)
{
strcpy(colname[i][j], rec2.pData + 21);
memcpy(&coltype[i][j], rec2.pData + 42, sizeof(AttrType));
memcpy(&collength[i][j], rec2.pData + 46, sizeof(int));
memcpy(&coloffset[i][j], rec2.pData + 50, sizeof(int));
if (*(rec2.pData + 54) == '1')
iscolindex[i][j] = 1;
else
iscolindex[i][j] = 0;
j++;
}
colnum[i] = j;
j = 0;
i++;
FileScan2.bOpen = 0;
}
*tabnum = i;
rc = RM_CloseFile(&fileHandle);
if (rc != SUCCESS) {
AfxMessageBox("关闭系统表文件失败");
}
rc = RM_CloseFile(&colfilehandle);
if (rc != SUCCESS) {
AfxMessageBox("关闭系统列文件失败");
}
delete[] rec1.pData;
delete[] rec2.pData;
return 1;
}
void CEditArea::ShowSelResult(int col_num, int row_num, char** fields, char*** result) {
CHustBaseDoc* pDoc = (CHustBaseDoc*)GetDocument();
for (int i = 0; i < col_num; i++) {
memcpy(pDoc->selResult[0][i], fields[i], 20);
}
for (int i = 0; i < row_num; i++) {
for (int j = 0; j < col_num; j++) {
memcpy(pDoc->selResult[i + 1][j], result[i][j], 20);
}
}
this->showSelResult(1 + row_num, col_num);
}
void CEditArea::showSelResult(int row_num, int col_num)
{
int i, j;
CHustBaseDoc* pDoc = (CHustBaseDoc*)GetDocument(); //实现各区域通信,通过文档信息
CMainFrame* main = (CMainFrame*)AfxGetApp()->m_pMainWnd; //获取窗口指针
CWnd* pPane = (CWnd*)main->m_wmSplitter1.GetPane(2, 0);
CClientDC dc(pPane);
CRect cr;
pPane->GetClientRect(cr);
COLORREF clr = dc.GetBkColor();
dc.FillSolidRect(cr, clr); //清空之前输出的文字;
CFont font;
font.CreatePointFont(118, "微软雅黑", NULL);//设置字体
CFont* pOldFont = dc.SelectObject(&font);
TEXTMETRIC tm;
dc.GetTextMetrics(&tm);
POINT point1 = { 1,1 }, point2 = { col_num * 180 + 1,1 },
point3 = { col_num * 180 + 1,row_num * 25 + 1 },
point4 = { 1, row_num * 25 + 1 };
POINT pframe[5];
pframe[0] = point1;
pframe[1] = point2;
pframe[2] = point3;
pframe[3] = point4;
CPen pen1(PS_SOLID, 3, RGB(100, 100, 100));
CPen* pOldPen = dc.SelectObject(&pen1);
dc.Polyline(pframe, 4);
dc.MoveTo(point4);
dc.LineTo(point1);
dc.SelectObject(pOldPen);
POINT pBegin, pEnd;
for (i = 1; i < row_num; i++)
{
pBegin.x = 1;
pBegin.y = 25 * i + 1;
pEnd.x = col_num * 180 + 1;
pEnd.y = 25 * i + 1;
dc.MoveTo(pBegin);
dc.LineTo(pEnd);
}
for (i = 1; i < col_num; i++)
{
pBegin.y = 1;
pBegin.x = 180 * i + 1;
pEnd.y = row_num * 25 + 1;
pEnd.x = 180 * i + 1;
dc.MoveTo(pBegin);
dc.LineTo(pEnd);
}
for (i = 0; i < row_num; i++)
for (j = 0; j < col_num; j++)
{
dc.TextOut(8 + j * 180, 4 + i * 25, pDoc->selResult[i][j]);
}
}
/*
0<=count<=5
消息最多不能超过五行
*/
void CEditArea::ShowMessage(int count, char* strs[]) {
CHustBaseDoc* pDoc = (CHustBaseDoc*)GetDocument();
pDoc->infoCount = count;
for (int i = 0; i < count && i < 5; i++) {
pDoc->Info[i] = strs[i];
}
displayInfo();
}