forked from AgoraIO/API-Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAGVideoTestWnd.cpp
More file actions
120 lines (90 loc) · 2.8 KB
/
AGVideoTestWnd.cpp
File metadata and controls
120 lines (90 loc) · 2.8 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
#include "stdafx.h"
#include "AGVideoTestWnd.h"
// CAGVideoTestWnd
IMPLEMENT_DYNAMIC(CAGVideoTestWnd, CWnd)
CAGVideoTestWnd::CAGVideoTestWnd()
: m_nVolRange(255)
, m_nCurVol(0)
, m_crVolbarFreeColor(RGB(32, 32, 32))
, m_crVolbarBusyColor(RGB(208, 208, 208))
, m_crVolbarBackColor(RGB(0x26, 0x26, 0x26))
, m_crBackColor(RGB(0x70, 0x70, 0x70))
, m_nVolbarWidth(15)
{
}
CAGVideoTestWnd::~CAGVideoTestWnd()
{
}
BEGIN_MESSAGE_MAP(CAGVideoTestWnd, CWnd)
ON_WM_PAINT()
ON_WM_CREATE()
ON_WM_SIZE()
END_MESSAGE_MAP()
// CAGVideoTestWnd Message handle
int CAGVideoTestWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CWnd::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: add you own creation code here
CRect rcChildRect;
DWORD dwWndStyle = WS_VISIBLE | WS_CHILD;
rcChildRect.SetRect(15, 0, lpCreateStruct->cx-30, lpCreateStruct->cy);
m_wndVideoWnd.Create(NULL, _T("AgoraVideoWnd"), dwWndStyle, rcChildRect, this, IDC_STATIC);
return 0;
}
void CAGVideoTestWnd::OnPaint()
{
// TODO: add message handle code here
CPaintDC dc(this);
CRect rcClient;
GetClientRect(&rcClient);
dc.FillSolidRect(0, 0, rcClient.Width(), rcClient.Height(), m_crBackColor);
dc.FillSolidRect(0, 0, m_nVolbarWidth, rcClient.Height(), m_crVolbarBackColor);
dc.FillSolidRect(rcClient.Width() - m_nVolbarWidth, 0, m_nVolbarWidth, rcClient.Height(), m_crVolbarBackColor);
int nMarkCount = rcClient.Height() / 5;
int nTopPoint = m_nCurVol*nMarkCount / m_nVolRange;
for (int nIndex = 0; nIndex < nMarkCount; nIndex++) {
if (nIndex <= nTopPoint) {
dc.FillSolidRect(0, rcClient.bottom - 5 * nIndex - 3, m_nVolbarWidth, 3, m_crVolbarBusyColor);
dc.FillSolidRect(rcClient.Width() - m_nVolbarWidth, rcClient.bottom - 5 * nIndex - 3, m_nVolbarWidth, 3, m_crVolbarBusyColor);
}
else {
dc.FillSolidRect(0, rcClient.bottom - 5 * nIndex - 3, m_nVolbarWidth, 3, m_crVolbarFreeColor);
dc.FillSolidRect(rcClient.Width() - m_nVolbarWidth, rcClient.bottom - 5 * nIndex - 3, m_nVolbarWidth, 3, m_crVolbarFreeColor);
}
}
}
void CAGVideoTestWnd::SetVolRange(int nRange)
{
if (nRange > 100 || nRange < 0)
nRange = 100;
m_nVolRange = nRange;
Invalidate(FALSE);
}
void CAGVideoTestWnd::SetCurVol(int nCurVol)
{
if (nCurVol < 0 || nCurVol > m_nVolRange)
nCurVol = 0;
CRect rcClient;
GetClientRect(&rcClient);
m_nCurVol = nCurVol;
RECT lrc;
lrc.left = 0;
lrc.right = m_nVolbarWidth;
lrc.top = 0;
lrc.bottom = rcClient.Height();
InvalidateRect(&lrc);
RECT rrc;
rrc.left = rcClient.Width() - m_nVolbarWidth;
rrc.right = rcClient.Width();
rrc.top = 0;
rrc.bottom = rcClient.Height();
InvalidateRect(&rrc);
}
void CAGVideoTestWnd::OnSize(UINT nType, int cx, int cy)
{
CWnd::OnSize(nType, cx, cy);
if (m_wndVideoWnd.GetSafeHwnd() != NULL)
m_wndVideoWnd.MoveWindow(15, 0, cx - 30, cy);
// TODO: add message handle code here
}