CallOut.cpp
3.38 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
/*
* 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 "CallOut.h"
#include "Info.h"
IMPLEMENT_DYNAMIC(CCallOut, CDialog)
CCallOut::CCallOut(CWnd* pParent /*=NULL*/)
: CDialog(CCallOut::IDD, pParent), m_posX(0), m_posY(0), m_intAgentOrOut(0)
{
m_BrushBK.CreateSolidBrush(RGB(250,250,250));
}
CCallOut::~CCallOut()
{
m_BrushBK.DeleteObject();
}
void CCallOut::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_RADIO_IN, m_rdoAgent);
DDX_Control(pDX, IDC_RADIO_OUT, m_rdoOut);
DDX_Control(pDX, IDOK, m_btnOK);
DDX_Control(pDX, IDCANCEL, m_btnCancel);
DDX_Control(pDX, IDC_EDIT_NUMBER, m_editNumber);
DDX_Text(pDX, IDC_EDIT_NUMBER, m_strNumber);
}
BOOL CCallOut::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: 在此添加额外的初始化
CRect rect;
GetWindowRect(&rect);
int w = rect.Width();
int h = rect.Height();
rect.left = m_posX;
rect.top = m_posY;
rect.right = rect.left + w;
rect.bottom = rect.top + h;
MoveWindow(&rect);
if(m_intAgentOrOut == 0)
{
m_rdoAgent.SetCheck(0);
m_rdoOut.SetCheck(1);
}
else
{
m_rdoAgent.SetCheck(1);
m_rdoOut.SetCheck(0);
}
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}
BEGIN_MESSAGE_MAP(CCallOut, CDialog)
ON_BN_CLICKED(IDOK, OnBnClickedOk)
ON_WM_CTLCOLOR()
ON_WM_ERASEBKGND()
END_MESSAGE_MAP()
void CCallOut::OnBnClickedOk()
{
// TODO: 在此添加控件通知处理程序代码
UpdateData(TRUE);
if(m_strNumber.Trim().IsEmpty())
{
CInfo info;
info.SetInfo(IDI_ICON_ERROR, "坐席工号或外线号码不能为空!");
info.DoModal();
return;
}
int agentcheck = m_rdoAgent.GetCheck();
int outcheck = m_rdoOut.GetCheck();
if(agentcheck ==0 && outcheck == 1)
{
m_intAgentOrOut = 0;//外线
}
else if(agentcheck == 1 && outcheck == 0)
{
m_intAgentOrOut = 1;//坐席
}
else
{
CInfo info;
info.SetInfo(IDI_ICON_ERROR, "坐席和外线需要至少选择一种!");
info.DoModal();
return;
}
//
OnOK();
}
HBRUSH CCallOut::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: 在此更改 DC 的任何属性
switch(pWnd->GetDlgCtrlID())
{
case IDC_RADIO_IN:
case IDC_RADIO_OUT:
pDC->SetBkColor(RGB(250,250,250));
return m_BrushBK;
break;
default:
break;
}
// TODO: 如果默认的不是所需画笔,则返回另一个画笔
return hbr;
}
BOOL CCallOut::OnEraseBkgnd(CDC* pDC)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
CRect rect;
CBrush *p_OldBrush = NULL;
p_OldBrush = pDC->SelectObject(&m_BrushBK);
pDC->GetClipBox(&rect);
pDC->FillRect(&rect, &m_BrushBK);
pDC->SelectObject(p_OldBrush);
p_OldBrush = NULL;
return TRUE;
//return CDialog::OnEraseBkgnd(pDC);
}
void CCallOut::SetPosition(LONG x, LONG y)
{
m_posX = x;
m_posY = y;
}
int CCallOut::GetAgentOrOut()
{
return m_intAgentOrOut;
}
CString &CCallOut::GetNumber()
{
return m_strNumber;
}