This repository was archived by the owner on Apr 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathPoolView.cpp
More file actions
138 lines (104 loc) · 3 KB
/
PoolView.cpp
File metadata and controls
138 lines (104 loc) · 3 KB
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
// PoolView.cpp : implementation of the CPoolView class
//
#include "stdafx.h"
#include "resource.h"
#include "PoolMonEx.h"
#include "PoolView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CPoolView
CPoolView::CPoolView() {
}
CPoolView::~CPoolView() {
}
BEGIN_MESSAGE_MAP(CPoolView, CWnd)
ON_WM_PAINT()
ON_WM_CREATE()
ON_WM_SIZE()
ON_WM_ERASEBKGND()
ON_COMMAND(ID_EDIT_COPY, &CPoolView::OnEditCopy)
ON_COMMAND(ID_VIEW_PAUSE, &CPoolView::OnViewPause)
ON_UPDATE_COMMAND_UI(ID_VIEW_PAUSE, &CPoolView::OnUpdateViewPause)
ON_COMMAND(ID_FILE_SAVE, &CPoolView::OnFileSave)
END_MESSAGE_MAP()
// CPoolView message handlers
BOOL CPoolView::PreCreateWindow(CREATESTRUCT& cs) {
if (!CWnd::PreCreateWindow(cs))
return FALSE;
cs.dwExStyle |= WS_EX_CLIENTEDGE | WS_EX_TRANSPARENT;
cs.style |= WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
cs.style &= ~WS_BORDER;
cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS,
::LoadCursor(NULL, IDC_ARROW), nullptr, NULL);
return TRUE;
}
void CPoolView::OnPaint() {
CPaintDC dc(this);
}
int CPoolView::OnCreate(LPCREATESTRUCT lpCreateStruct) {
if (CWnd::OnCreate(lpCreateStruct) == -1)
return -1;
m_List.Create(WS_CHILD | WS_VISIBLE | LVS_REPORT | LVS_SHOWSELALWAYS | LVS_SINGLESEL | WS_CLIPSIBLINGS, CRect(), this, 123);
m_List.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_AUTOSIZECOLUMNS | LVS_EX_DOUBLEBUFFER);
return 0;
}
void CPoolView::OnSize(UINT nType, int cx, int cy) {
CWnd::OnSize(nType, cx, cy);
m_List.MoveWindow(0, 0, cx, cy, FALSE);
}
BOOL CPoolView::OnEraseBkgnd(CDC* pDC) {
return TRUE;
}
void CPoolView::OnEditCopy() {
// TODO: Add your command handler code here
}
BOOL CPoolView::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) {
if (m_List.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
return TRUE;
return CWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
}
void CPoolView::OnViewPause() {
m_Paused = !m_Paused;
m_List.Pause(m_Paused);
}
void CPoolView::OnUpdateViewPause(CCmdUI *pCmdUI) {
pCmdUI->SetText(m_Paused ? L"Resume" : L"Pause");
}
void CPoolView::OnFileSave() {
CFileDialog dlg(FALSE, L".csv", nullptr, OFN_EXPLORER | OFN_OVERWRITEPROMPT, L"CSV Files|*.csv|All Files|*.*||", this);
if (dlg.DoModal() == IDOK) {
try {
CFile file(dlg.GetPathName(), CFile::modeWrite | CFile::modeCreate);
CArchive ar(&file, CArchive::store);
int column = 0;
TCHAR text[128];
while(true) {
LVCOLUMN col;
col.mask = LVCF_TEXT;
col.cchTextMax = 128;
col.pszText = text;
if (!m_List.GetColumn(column, &col))
break;
ar.WriteString(col.pszText);
ar.WriteString(L",");
column++;
}
ar.WriteString(L"\n");
int count = m_List.GetItemCount();
for (int i = 0; i < count; i++) {
for (int c = 0; c < column; c++) {
ar.WriteString(m_List.GetItemText(i, c));
ar.WriteString(L",");
}
ar.WriteString(L"\n");
}
}
catch (CFileException* ex) {
TCHAR msg[256];
ex->GetErrorMessage(msg, 256);
AfxMessageBox(msg);
ex->Delete();
}
}
}