AgentFrameView.cpp
7.35 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
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
/*
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* CC/LICENSE
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "stdafx.h"
#include "AgentMonitor.h"
#include "AgentFrameView.h"
#include ".\agentframeview.h"
#include "SkillGroupTreeView.h"
#include "DataMgr.h"
#include "SysInfoFormView.h"
#include "AgentDetailFormView.h"
#include "QueueDetailFormView.h"
// CAgentFrameView
IMPLEMENT_DYNCREATE(CAgentFrameView, CFrameWnd)
CAgentFrameView::CAgentFrameView()
{
this->m_pContext = NULL;
}
CAgentFrameView::~CAgentFrameView()
{
if(this->m_pWndSplitterV)
delete m_pWndSplitterV;
}
BEGIN_MESSAGE_MAP(CAgentFrameView, CFrameWnd)
ON_MESSAGE(WM_DISPLAYSYSINFO, OnGetSysInfo)
ON_MESSAGE(WM_DISPLAYAGENTINFO, OnAgentInfo)
END_MESSAGE_MAP()
// CAgentFrameView 消息处理程序
BOOL CAgentFrameView::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
// TODO: 在此添加专用代码和/或调用基类
this->m_pContext = pContext;
CDataMgr::getInstance()->m_hAgentFrameView=this->GetSafeHwnd();
m_wndSplitterH.CreateStatic(this,1,2); // 对整个窗口进行分割,共一行,二列
m_wndSplitterH.CreateView(0,0,RUNTIME_CLASS(CSkillGroupTreeView),CSize(200,0),pContext); // 第0行第0列的视图是CSkillGroupTreeView,列宽为360
m_pWndSplitterV = new CSplitterWnd();
if( !m_pWndSplitterV->CreateStatic(&m_wndSplitterH,2,1,WS_CHILD|WS_VISIBLE,m_wndSplitterH.IdFromRowCol(0,1)))
return FALSE;
m_pWndSplitterV->CreateView(0,0,RUNTIME_CLASS(CAgentDetailFormView),CSize(0,400),pContext);
m_pWndSplitterV->CreateView(1,0,RUNTIME_CLASS(CQueueDetailFormView),CSize(0,100),pContext);
return TRUE;
}
LRESULT CAgentFrameView::OnGetSysInfo(WPARAM wParam, LPARAM lParam)
{
// LONGLONG address = MAKELONGLONG(wParam, lParam);
// char* skill = reinterpret_cast<char *>(address);
/*
CCreateContext context;
BOOL bSetActive;
// ((CSplitter *)GetParent())->ReplaceView(0,1,RUNTIME_CLASS(CView1), size);
CRuntimeClass* pViewClass = RUNTIME_CLASS(CSysInfoFormView);
if ((this->m_wndSplitterH.GetPane(0,1)->IsKindOf(pViewClass))==TRUE)
return FALSE;
// Get pointer to CDocument object so that it can be used in the creation
// process of the new view
CDocument * pDoc= ((CView *)this->m_wndSplitterH.GetPane(0,1))->GetDocument();
CView * pActiveView=this->m_wndSplitterH.GetParentFrame()->GetActiveView();
if (pActiveView==NULL || pActiveView==this->m_wndSplitterH.GetPane(0,1))
bSetActive=TRUE;
else
bSetActive=FALSE;
// set flag so that document will not be deleted when view is destroyed
//pDoc->m_bAutoDelete=FALSE;
// Delete existing view
((CView *) this->m_wndSplitterH.GetPane(0,1))->DestroyWindow();
// set flag back to default
//pDoc->m_bAutoDelete=TRUE;
// Create new view
context.m_pNewViewClass=pViewClass;
context.m_pCurrentDoc=pDoc;
context.m_pNewDocTemplate=NULL;
context.m_pLastView=NULL;
context.m_pCurrentFrame=NULL;
this->m_wndSplitterH.CreateView(0,1,pViewClass,CSize(0,100), &context);
CView * pNewView= (CView *)this->m_wndSplitterH.GetPane(0,1);
if (bSetActive==TRUE)
GetParentFrame()->SetActiveView(pNewView);
RecalcLayout();
this->m_wndSplitterH.GetPane(0,1)->SendMessage(WM_PAINT);
//this->Invalidate();
pNewView->ShowWindow(SW_SHOW);
*/
CRuntimeClass* pViewClass = RUNTIME_CLASS(CSysInfoFormView);
if ((this->m_wndSplitterH.GetPane(0,1)->IsKindOf(pViewClass)))
return FALSE;
((CView *) this->m_wndSplitterH.GetPane(0,1))->DestroyWindow();
delete this->m_pWndSplitterV;
this->m_pWndSplitterV = NULL;
this->m_wndSplitterH.CreateView(0,1,pViewClass,CSize(0,100), m_pContext);
CView * pNewView= (CView *)this->m_wndSplitterH.GetPane(0,1);
this->m_wndSplitterH.RecalcLayout();
this->m_wndSplitterH.GetPane(0,1)->SendMessage(WM_PAINT);
return 0;
}
LRESULT CAgentFrameView::OnAgentInfo(WPARAM wParam, LPARAM lParam)
{
// LONGLONG address = MAKELONGLONG(wParam, lParam);
// char* skill = reinterpret_cast<char *>(address);
/*
CCreateContext context;
BOOL bSetActive;
// ((CSplitter *)GetParent())->ReplaceView(0,1,RUNTIME_CLASS(CView1), size);
CRuntimeClass* pViewClass = RUNTIME_CLASS(CSysInfoFormView);
if ((this->m_wndSplitterH.GetPane(0,1)->IsKindOf(pViewClass))==TRUE)
return FALSE;
// Get pointer to CDocument object so that it can be used in the creation
// process of the new view
CDocument * pDoc= ((CView *)this->m_wndSplitterH.GetPane(0,1))->GetDocument();
CView * pActiveView=this->m_wndSplitterH.GetParentFrame()->GetActiveView();
if (pActiveView==NULL || pActiveView==this->m_wndSplitterH.GetPane(0,1))
bSetActive=TRUE;
else
bSetActive=FALSE;
// set flag so that document will not be deleted when view is destroyed
//pDoc->m_bAutoDelete=FALSE;
// Delete existing view
((CView *) this->m_wndSplitterH.GetPane(0,1))->DestroyWindow();
// set flag back to default
//pDoc->m_bAutoDelete=TRUE;
// Create new view
context.m_pNewViewClass=pViewClass;
context.m_pCurrentDoc=pDoc;
context.m_pNewDocTemplate=NULL;
context.m_pLastView=NULL;
context.m_pCurrentFrame=NULL;
this->m_wndSplitterH.CreateView(0,1,pViewClass,CSize(0,100), &context);
CView * pNewView= (CView *)this->m_wndSplitterH.GetPane(0,1);
if (bSetActive==TRUE)
GetParentFrame()->SetActiveView(pNewView);
RecalcLayout();
this->m_wndSplitterH.GetPane(0,1)->SendMessage(WM_PAINT);
//this->Invalidate();
pNewView->ShowWindow(SW_SHOW);
*/
/*
CRuntimeClass* pViewClass = RUNTIME_CLASS(CAgentDetailFormView);
if ((this->m_wndSplitterH.GetPane(0,1)->IsKindOf(pViewClass))==TRUE)
return FALSE;
((CView *) this->m_wndSplitterH.GetPane(0,1))->DestroyWindow();
this->m_wndSplitterH.CreateView(0,1,pViewClass,CSize(0,100), m_pContext);
CView * pNewView= (CView *)this->m_wndSplitterH.GetPane(0,1);
this->m_wndSplitterH.RecalcLayout();
this->m_wndSplitterH.GetPane(0,1)->SendMessage(WM_PAINT);
*/
/*
if(! m_wndSplitterV.CreateStatic(&m_wndSplitterH,2,1,WS_CHILD|WS_VISIBLE,m_wndSplitterH.IdFromRowCol(0,1)))
return FALSE;
m_wndSplitterV.CreateView(0,0,pViewClass,CSize(0,400),m_pContext);
m_wndSplitterV.CreateView(1,0,RUNTIME_CLASS(CQueueDetailFormView),CSize(0,100),m_pContext);
this->m_wndSplitterV.GetPane(0,0)->SendMessage(WM_PAINT);
*/
// CRuntimeClass* pViewClass = m_pWndSplitterV->GetRuntimeClass();
if (this->m_pWndSplitterV)
return FALSE;
this->m_pWndSplitterV = new CSplitterWnd();
((CView *) this->m_wndSplitterH.GetPane(0,1))->DestroyWindow();
if(! m_pWndSplitterV->CreateStatic(&m_wndSplitterH,2,1,WS_CHILD|WS_VISIBLE,m_wndSplitterH.IdFromRowCol(0,1)))
return FALSE;
m_pWndSplitterV->CreateView(0,0,RUNTIME_CLASS(CAgentDetailFormView),CSize(0,400),m_pContext);
m_pWndSplitterV->CreateView(1,0,RUNTIME_CLASS(CQueueDetailFormView),CSize(0,100),m_pContext);
//this->m_wndSplitterH.CreateView(0,1,pViewClass,CSize(0,100), m_pContext);
CView * pNewView= (CView *)this->m_pWndSplitterV->GetPane(0,0);
this->m_wndSplitterH.RecalcLayout();
pNewView->SendMessage(WM_PAINT);
return TRUE;
}