-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForwardButton.cpp
More file actions
121 lines (86 loc) · 2.33 KB
/
ForwardButton.cpp
File metadata and controls
121 lines (86 loc) · 2.33 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
// ForwardButton.cpp : implementation file
//
#include "stdafx.h"
#include "MediaPlayer.h"
#include "ForwardButton.h"
#include "MediaPlayerDialog.h"
// CForwardButton
IMPLEMENT_DYNAMIC(CForwardButton, CButton)
CForwardButton::CForwardButton()
{
m_pMediaPlayerDlg = nullptr;
}
CForwardButton::~CForwardButton()
{
}
BEGIN_MESSAGE_MAP(CForwardButton, CButton)
ON_WM_LBUTTONDOWN()
END_MESSAGE_MAP()
// CForwardButton message handlers
void CForwardButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
// TODO: Add your code to draw the specified item
CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
ASSERT(pDC != NULL);
UINT uStyle = DFCS_BUTTONPUSH;
// This code only works with buttons.
ASSERT(lpDrawItemStruct->CtlType == ODT_BUTTON);
// If drawing selected, add the pushed style to DrawFrameControl.
if (lpDrawItemStruct->itemState & ODS_SELECTED)
uStyle |= DFCS_PUSHED;
// Draw the button frame.
::DrawFrameControl(lpDrawItemStruct->hDC, &lpDrawItemStruct->rcItem,
DFC_BUTTON, uStyle);
DrawForwardIcon(*pDC, lpDrawItemStruct->rcItem);
}
void CForwardButton::DrawForwardIcon(CDC& dc, const RECT& rect)
{
CRect rt(rect.left, rect.top, rect.right, rect.bottom);
rt.DeflateRect(3, 3, 3, 3);
long lTop = rt.top;
long lTop_ = lTop;
long lBottom = rt.bottom;
long lBottom_ = lBottom;
long lCenter = rt.left + (rt.right - rt.left) / 2;
long lCenter_ = lCenter;
long lHeight = rt.bottom - rt.top;
long lRight = rt.right - 3;
long lLeft = rt.left + 3;
const long lIncrease = 1L;
while (true)
{
if (lTop >= lBottom)
{
break;
}
dc.MoveTo(lLeft, lTop);
dc.LineTo(lLeft, lBottom);
lLeft += 1;
lTop += lIncrease;
lBottom -= lIncrease;
}
while (true)
{
if (lTop_ >= lBottom_)
{
break;
}
dc.MoveTo(lCenter, lTop_);
dc.LineTo(lCenter, lBottom_);
lCenter += 1;
lTop_ += lIncrease;
lBottom_ -= lIncrease;
}
}
void CForwardButton::SetParentDlg(CMediaPlayerDialog* pDlg)
{
if (pDlg)
{
m_pMediaPlayerDlg = pDlg;
}
}
void CForwardButton::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CButton::OnLButtonDown(nFlags, point);
}