Repository navigation
Expand file tree
/
Copy pathEM_RecvChat.cpp
More file actions
138 lines (116 loc) · 3.11 KB
/
Copy pathEM_RecvChat.cpp
File metadata and controls
138 lines (116 loc) · 3.11 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
// EM_RecvChat.cpp : implementation file
// Download by http://www.codefans.net
#include "stdafx.h"
#include "EIM02.h"
#include "EM_RecvChat.h"
#include "em/stdemdef.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// EM_RecvChat dialog
EM_RecvChat::EM_RecvChat(CWnd* pParent /*=NULL*/)
: CDialog(EM_RecvChat::IDD, pParent)
{
//{{AFX_DATA_INIT(EM_RecvChat)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_bChatting = FALSE;
}
void EM_RecvChat::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(EM_RecvChat)
// NOTE: the ClassWizard will add DDX and DDV calls here
DDX_Control(pDX, IDC_PROGRESS1, m_process);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(EM_RecvChat, CDialog)
//{{AFX_MSG_MAP(EM_RecvChat)
ON_BN_CLICKED(IDC_ACCEPT, OnAccept)
ON_BN_CLICKED(IDC_DENY, OnDeny)
ON_WM_TIMER()
ON_WM_SHOWWINDOW()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// EM_RecvChat message handlers
void EM_RecvChat::OnAccept()
{
// TODO: Add your control notification handler code here
CWnd *pWnd = GetParent();
pWnd->PostMessage(WM_SRCACCEPTCHAT);
KillTimer(33);
GetDlgItem(IDC_ACCEPT)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_STATIC6)->ShowWindow(SW_HIDE);
m_process.ShowWindow(SW_HIDE);
m_bChatting = TRUE;
GetDlgItem(IDC_DENY)->SetWindowText("结束通话(&T)");
CRect rect;
GetDlgItem(IDC_STATIC8)->GetWindowRect(&rect);
ScreenToClient(&rect);
rect.right += 170;
GetDlgItem(IDC_STATIC8)->MoveWindow(&rect);
SetTimer(55, 1000, NULL);
// 启动收听线程
m_pwo = (CWaveOut*)AfxBeginThread(
RUNTIME_CLASS(CWaveOut),
THREAD_PRIORITY_HIGHEST, 0, CREATE_SUSPENDED);
m_pwo->SetIP(m_strIP);
// AfxMessageBox(m_strIP);
m_pwo->ResumeThread();
// GetDlgItem(IDC_STATIC88)->SetWindowText(m_strIP);
// CDialog::OnOK();
}
void EM_RecvChat::OnDeny()
{
// TODO: Add your control notification handler code here
if (! m_bChatting)
{
CWnd *pWnd = GetParent();
pWnd->PostMessage(WM_EMDONOTCHAT, 0, sizeof(DWORD));
CDialog::OnOK();
}
else
{
CWnd *pWnd = GetParent();
pWnd->PostMessage(WM_EMDONOTCHAT, 1, sizeof(DWORD));
if (m_pwo)
m_pwo->Stop();
}
}
void EM_RecvChat::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
static DWORD nSecond = 0;
if (33 == nIDEvent)
{
int nPos = m_process.StepIt();
CString str;
str.Format("将在 %d 秒后自动取消", int((100-nPos)/10)+1);
GetDlgItem(IDC_STATIC6)->SetWindowText(str);
if (100 == nPos)
{
KillTimer(nIDEvent);
OnDeny();
}
}
if (55 == nIDEvent)
{
CString str;
str.Format(_T("语音对话 对话进行中,通话时间 %d 秒。"), nSecond++);
GetDlgItem(IDC_STATIC8)->SetWindowText(str);
}
CDialog::OnTimer(nIDEvent);
}
void EM_RecvChat::OnShowWindow(BOOL bShow, UINT nStatus)
{
CDialog::OnShowWindow(bShow, nStatus);
// TODO: Add your message handler code here
GetDlgItem(IDC_ACCEPT)->SetFocus();
m_process.SetRange(1, 100);
m_process.SetStep(1);
SetTimer(33, 100, NULL);
}