⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 animateicon.cpp

📁 处理各种电话投诉的危机情况
💻 CPP
字号:

/////////////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "AnimateIcon.h"
#include "DBtest.h"  //包含资源文件

// default constructor
CAnimateIcon::CAnimateIcon()
{
	m_iImageCounter = -1;
	m_iMaxNoOfImages = -99;
	m_imgList.m_hImageList = NULL;
    //载入两个图标文件
	hIcon[0]=AfxGetApp()->LoadIcon(IDI_PHONE);
	hIcon[1]=AfxGetApp()->LoadIcon(IDI_PHONERNG);
}

// default do nothing destructor
CAnimateIcon::~CAnimateIcon()
{
	if (hPrevIcon) 
		DestroyIcon(hPrevIcon);
}

// This is the first function which needs to be called in order
// to fill the image list
// Parameters :
// ------------
// int IDOfImgListResource - pass the Resource ID of a toolbar resource
//                           containing the image list
// int numberOfImages      - Number of images (16x16) in the toolbar resource
// transparentColor        - RGB value of color you want to be transparent
BOOL CAnimateIcon::SetImageList(int IDOfImgListResource,int numberOfImages,COLORREF transparentColor)
{
	if(numberOfImages <= 0)
		return FALSE;
	m_iMaxNoOfImages = numberOfImages;
	VERIFY(m_imgList.Create(IDOfImgListResource,16,1,transparentColor));
	return TRUE;
}

// This function needs to be called repetatively to show next image
// Parameters :
// ------------
// NONE

BOOL CAnimateIcon::ShowNextImage()
{
	if(m_imgList.m_hImageList == NULL)
		return FALSE;
	m_iImageCounter++; //图标循环索引号
	if(m_iImageCounter >= m_iMaxNoOfImages)
		m_iImageCounter =0;

	// extract the icon from imagelist

	//不用位图文件IDI_ANI,而用IDI_PHONE和IDI_PHONERNG两个图标文件交替实现动画,以消除程序最小化时图标显示不透明问题
	//hIcon = m_imgList.ExtractIcon(m_iImageCounter);

	// send the message to frame to update icon
	HICON hPrevIcon = (HICON) 	AfxGetMainWnd()->SendMessage(WM_SETICON,TRUE,(LPARAM)hIcon[m_iImageCounter]);	
	// Free the previous icon resource
	if (hPrevIcon) 	
	    DestroyIcon(hPrevIcon);
	return TRUE;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -