>LineTo(rect.Width()-1,rect.Height()-1); pDC->LineTo(0,rect.Height()-1); pDC->MoveTo(rect.Width()-2,1); pDC->LineTo(rect.Width()-2,rect.Height()-2); pDC->LineTo(0,rect.Height()-2); if (pen2Created)//删除"pen2"画笔对象 { pen2.DeleteObject(); pen2Created = FALSE; } if (pen1Created = pen1.CreatePen(PS_SOLID, 1, edgeCol)) pOldPen = pDC->SelectObject( &;pen1 ); if (pen1Created) { pen1.DeleteObject(); pen1Created = FALSE; } if (pOldPen != NULL) pDC->SelectObject( pOldPen ); } void CAviButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { // TODO: Add your code to draw the specified item CRect rect; GetClientRect(rect); if (!::IsWindow(AnimateCtrl)) { //在按钮上生成一个动画控件 AnimateCtrl.Create(WS_CHILD |WS_VISIBLE,rect,this,0); //打开avi文件并显示第一帧 AnimateCtrl.Open(m_nAviID); AnimateCtrl.GetClientRect(rect);
} CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC); UINT nState = lpDrawItemStruct->itemState; CRect buttonRect; GetClientRect(buttonRect); //绘制按钮 DrawButton(pDC, nState, buttonRect); } BOOL CAviButton::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT&; rect, CWnd* pParentWnd, UINT nID,
CCreateContext* pContext) { // TODO: Add your specialized code here and/or call the base class return CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext); } void CAviButton::OnMouseMove(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default ClientToScreen(&;point); CRect rcWindow; GetWindowRect(rcWindow); //判断鼠标是否经过按钮 BOOL bNewMouseOverButton = rcWindow.PtInRect(point); if (bNewMouseOverButton &;&; IsWindowEnabled() ) { if (::IsWindow(AnimateCtrl) &;&; !bPlaying) { AnimateCtrl.Play(0,-1,1); bPlaying = TRUE; SetCapture(); } } else { bPlaying = FALSE; ReleaseCapture(); } CButton::OnMouseMove(nFlags, point); } /////////////////