Add the following code in CTestanimctrlView::OnInitialUpdate: // 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 Add ON_MN_CTLCOLOR() into the message map: BEGIN_MESSAGE_MAP(CTestanimctrlView, CView) //{{AFX_MSG_MAP(CTestanimctrlView) ON_WM_CTLCOLOR() END_MESSAGE_MAP() Add the message handler for WM_CTLCOLOR: 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; } Free up the memory used by the animate control: CTestanimctrlView::~CTestanimctrlView() { if (m_pMyAnimateCtrl) { m_pMyAnimateCtrl->DestroyWindow(); delete m_pMyAnimateCtrl; } }
HOWTO: Display CAnimateCtrl with Transparent Background Q179907 -------------------------------------------------------------------------------- The information in this article applies to:Microsoft Win32 Software Development Kit (SDK) The Microsoft Foundation Classes (MFC), used with: Microsoft Visual C++, 32-bit Editions, versions 4.0, 4.0a, 4.1, 4.2b Microsoft Visual C++, 32-bit Enterprise Edition, version 4.2 Microsoft Visual C++, 32-bit Professional Edition, version 4.2 Microsoft Visual C++, 32-bit Enterprise Edition, version 5.0 Microsoft Visual C++, 32-bit Professional Edition, version 5.0-------------------------------------------------------------------------------- SUMMARY This article shows how to display .avi files with a transparent background. The CAnimateCtrl control supports .avi files with a transparent background with a limitation of 16 colors. The first pixel in the first frame of an .avi file determines the background color of the CAnimateCtrl control.
SUMMARY This article shows how to display .avi files with a transparent background. The CAnimateCtrl control supports .avi files with a transparent background with a limitation of 16 colors. The first pixel in the first frame of an .avi file determines the background color of the CAnimateCtrl control. 只有16色,我的avi是xp中shell32.dll的放入回收站,用了kb中的方法没有显示出avi,还有什么方法吗,感谢
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
Add ON_MN_CTLCOLOR() into the message map: BEGIN_MESSAGE_MAP(CTestanimctrlView, CView)
//{{AFX_MSG_MAP(CTestanimctrlView)
ON_WM_CTLCOLOR()
END_MESSAGE_MAP()
Add the message handler for WM_CTLCOLOR: 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;
}
Free up the memory used by the animate control: CTestanimctrlView::~CTestanimctrlView()
{
if (m_pMyAnimateCtrl) {
m_pMyAnimateCtrl->DestroyWindow();
delete m_pMyAnimateCtrl;
}
}
--------------------------------------------------------------------------------
The information in this article applies to:Microsoft Win32 Software Development Kit (SDK)
The Microsoft Foundation Classes (MFC), used with:
Microsoft Visual C++, 32-bit Editions, versions 4.0, 4.0a, 4.1, 4.2b
Microsoft Visual C++, 32-bit Enterprise Edition, version 4.2
Microsoft Visual C++, 32-bit Professional Edition, version 4.2
Microsoft Visual C++, 32-bit Enterprise Edition, version 5.0
Microsoft Visual C++, 32-bit Professional Edition, version 5.0--------------------------------------------------------------------------------
SUMMARY
This article shows how to display .avi files with a transparent background. The CAnimateCtrl control supports .avi files with a transparent background with a limitation of 16 colors. The first pixel in the first frame of an .avi file determines the background color of the CAnimateCtrl control.
This article shows how to display .avi files with a transparent background. The CAnimateCtrl control supports .avi files with a transparent background with a limitation of 16 colors. The first pixel in the first frame of an .avi file determines the background color of the CAnimateCtrl control. 只有16色,我的avi是xp中shell32.dll的放入回收站,用了kb中的方法没有显示出avi,还有什么方法吗,感谢