Article ID: 179907
Article Last Modified on 7/11/2005
CAnimateCtrl* m_pMyAnimateCtrl;
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
Add the following code into the .cpp file of CTestanimctrlView:
// Create my animate control.
m_pMyAnimateCtrl = new CAnimateCtrl;
UINT styles = WS_CHILD | ACS_TRANSPARENT | ACS_AUTOPLAY;
m_pMyAnimateCtrl->Create(styles, CRect(100, 50, 300, 300), this,
ID_MYANIM); // here ID_MYANIM is the ID of m_pMyAnimateCtrl
BEGIN_MESSAGE_MAP(CTestanimctrlView, CView)
//{{AFX_MSG_MAP(CTestanimctrlView)
ON_WM_CTLCOLOR()
END_MESSAGE_MAP()
HBRUSH CCTestanimctrlView::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT
nCtlColor)
{
UINT id = pWnd->GetDlgCtrlID();
if (id == ID_MYANIM)
return (HBRUSH)GetStockObject(NULL_BRUSH);
HBRUSH hbr = CView::OnCtlColor(pDC, pWnd, nCtlColor);
return hbr;
}
CTestanimctrlView::~CTestanimctrlView()
{
if (m_pMyAnimateCtrl) {
m_pMyAnimateCtrl->DestroyWindow();
delete m_pMyAnimateCtrl;
}
}Keywords: kbhowto kbanimation kbctrl KB179907