-
Notifications
You must be signed in to change notification settings - Fork 0
/
AniButton.cpp
128 lines (91 loc) · 2.37 KB
/
AniButton.cpp
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
// AniButton.cpp : implementation file
//
#include "stdafx.h"
#include "AniButton.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//REMEMBER TO SET BUTTON TEXT VERTICAL POSITION AS 'BOTTOM' OR ELSE IT WILL GET HIDDEN BEHIND THE AVI!!
/////////////////////////////////////////////////////////////////////////////
// CAniButton
CAniButton::CAniButton()
{
m_bRedrawFlag=TRUE;
}
CAniButton::~CAniButton()
{
}
BEGIN_MESSAGE_MAP(CAniButton, CButton)
//{{AFX_MSG_MAP(CAniButton)
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_MOUSEMOVE()
ON_WM_MBUTTONUP()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAniButton message handlers
void CAniButton::OnLButtonDown(UINT nFlags, CPoint point)
{
CButton::OnLButtonDown(nFlags, point);
if (m_bRedrawFlag)
m_ctlAnimate.RedrawWindow();
}
void CAniButton::OnLButtonUp(UINT nFlags, CPoint point)
{
CButton::OnLButtonUp(nFlags, point);
if (m_bRedrawFlag)
m_ctlAnimate.RedrawWindow();
}
void CAniButton::OnMouseMove(UINT nFlags, CPoint point)
{
CButton::OnMouseMove(nFlags, point);
if (nFlags!=0)
if (m_bRedrawFlag)
m_ctlAnimate.RedrawWindow();
}
void CAniButton::Play()
{
m_bRedrawFlag=FALSE;
m_ctlAnimate.Play(0,-1,-1);
}
void CAniButton::Close()
{
m_bRedrawFlag=FALSE;
m_ctlAnimate.Close();
}
void CAniButton::Stop()
{
m_ctlAnimate.Stop();
}
BOOL CAniButton::Open( LPCTSTR lpszFileName )
{
TRACE("Open lpszfilename called\n");
if (!::IsWindow(m_ctlAnimate))
{
CRect arect;
GetClientRect(&arect);
arect.DeflateRect(8,arect.Height()/5.0);
arect.OffsetRect(0,-arect.Height()/5.0);
m_ctlAnimate.Create(WS_CHILD | WS_VISIBLE | ACS_TRANSPARENT,arect,this,5000);//IDC_ANIMATE1);
}
m_bRedrawFlag=TRUE;
return m_ctlAnimate.Open(lpszFileName);
}
BOOL CAniButton::Open( UINT nID )
{
TRACE("Open id called\n");
if (!::IsWindow(m_ctlAnimate))
{
CRect arect;
GetClientRect(&arect);
arect.DeflateRect(8,arect.Height()/5.0);
arect.OffsetRect(0,-arect.Height()/5.0);
m_ctlAnimate.Create(WS_CHILD | WS_VISIBLE | ACS_TRANSPARENT |ACS_CENTER ,arect,this,5000);//IDC_ANIMATE1);
}
//if you change the Create call to include ACS_AUTOPLAY, then do not set m_bRedrawFlag to TRUE
m_bRedrawFlag=TRUE;
return m_ctlAnimate.Open(nID);
}