-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMSGDLG.cpp
More file actions
106 lines (82 loc) · 2.02 KB
/
MSGDLG.cpp
File metadata and controls
106 lines (82 loc) · 2.02 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
// MSGDLG.cpp : implementation file
//
#include "stdafx.h"
#include "TestxRTCDemo.h"
#include "MSGDLG.h"
#include "afxdialogex.h"
// CMSGDLG dialog
IMPLEMENT_DYNAMIC(CMSGDLG, CDialogEx)
CMSGDLG::CMSGDLG(handle_t xRoom, CWnd* pParent /*=NULL*/)
: CDialogEx(IDD_MGSDLG, pParent)
{
m_xRtcGlobalRoom = xRoom;
}
CMSGDLG::~CMSGDLG()
{
}
void CMSGDLG::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CMSGDLG, CDialogEx)
ON_BN_CLICKED(IDC_SEND, &CMSGDLG::OnBnClickedSend)
END_MESSAGE_MAP()
BOOL CMSGDLG::OnInitDialog()
{
CDialogEx::OnInitDialog();
if (!m_msgShow.IsEmpty())
{
CEdit* pEdit = (CEdit*)GetDlgItem(IDC_SHOW);
pEdit->SetSel(-1, -1);
pEdit->ReplaceSel(m_msgShow);
}
return true;
}
// CMSGDLG message handlers
void CMSGDLG::ShowMessage(const char* userid, const char* lpmsg)
{
m_msgShow.Format("\r\n[收到来自 %s 的消息]", userid);
m_msgShow.Append(lpmsg);
if (!m_hWnd)
return;
CEdit* pEdit = (CEdit*)GetDlgItem(IDC_SHOW);
pEdit->SetSel(-1, -1);
pEdit->ReplaceSel(m_msgShow);
}
void CMSGDLG::ShowSendResult(const char* userid, const char* lpmsg, int ec)
{
if (0 == ec)
{
m_msgShow.Format("\r\n[发给 %s 的消息] ", userid);
m_msgShow.Append(lpmsg);
CEdit* pEdit = (CEdit*)GetDlgItem(IDC_SHOW);
pEdit->SetSel(-1, -1);
pEdit->ReplaceSel(m_msgShow);
}
else
{
SetDlgItemText(IDC_INPUT, lpmsg);
CString msg;
msg.Format("发送失败,错误: %s", Valley_GetErrDesc(ec));
AfxMessageBox(msg);
}
}
void CMSGDLG::OnBnClickedSend()
{
CString strmsg;
CString toUserID;
GetDlgItemTextA(IDC_INPUT, strmsg);
GetDlgItemTextA(IDC_RECVER, toUserID);
if (toUserID.IsEmpty())
{
AfxMessageBox("接收者不能为空");
return;
}
if (strmsg.IsEmpty())
{
AfxMessageBox("消息内容不能为空");
return;
}
Valley_SendMsgr(m_xRtcGlobalRoom, msgtypeText, (const char*)strmsg, strmsg.GetLength() + 1, nullptr, (const char*)toUserID);
SetDlgItemText(IDC_INPUT, "");
}