如何动画任务栏上的图标
在TrayIcon类中加入下列两个函数:
BOOL CTrayIcon::SetAnimateIcons(HICON* hIcon, UINT Number)
{//设置动画图标
ASSERT(Number >= 2);//图标必须为两个以上
ASSERT(hIcon);//图标必须不为空
m_AnimateIcons = new HICON[Number];
CopyMemory(m_AnimateIcons, hIcon, Number * sizeof(HICON));
m_AnimateIconsNumber = Number;
return TRUE;
}
BOOL CTrayIcon::Animate(UINT Index)
{//动画TrayIcon
UINT i = Index % m_AnimateIconsNumber;
return ChangeIcon(m_AnimateIcons[i]);
}
怎样在应用程序中添加相应的菜单和函数
void CMainFrame::OnMenuAnimate()
{//动画TrayIcon,设置图标及定时器
SetTimer(1, 500, NULL);
HICON hIcon;
hIcon[0] = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
hIcon = AfxGetApp()->LoadIcon(IDR_MYTURNTYPE);
hIcon = AfxGetApp()->LoadStandardIcon(IDI_HAND);
trayicon.SetAnimateIcons(hIcon, 3);
}
void CMainFrame::OnTimer(UINT nIDEvent)
{//动画TrayIcon
UINT static i;
i += 1;
trayicon.Animate(i);
CMDIFrameWnd::OnTimer(nIDEvent);
}