Chinaunix首页 | 论坛 | 博客
  • 博客访问: 735295
  • 博文数量: 769
  • 博客积分: 6000
  • 博客等级: 准将
  • 技术积分: 4985
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-15 16:37
文章分类

全部博文(769)

文章存档

2011年(1)

2008年(768)

我的朋友

分类:

2008-10-15 16:40:11

  1.用AppWizard创建一个SDI空工程WndStyle;
 
  2.在窗口的标题栏增加动画图标;
 
  (1)创建位图资源,并按序放置所有位图文件(16*16);
 
  (2)在工程工作区选择ResourceView面板,右击任一资源项。在弹出的快捷菜单中选择“Insert……”命令,打开“Insert Source”对话框。
 
  (3)在“Resurece Type”列表框中选择“Bitmap”项,然后单击右边的“Import”按钮。
 
  (4)打开“Import Resource”对话框,在文件列表框中选择要插入的位图文件,单击“Improt”按钮,插入选定的位图,然后将位图的ID值修改为需要的值“IDB_ANIM_IMGLIST”。
 
  3.增加管理位图动画的文件;这里采用CImageList管理动画需要的多幅位图,因此需将AnimateIcon.cpp和AnimateIcon.h添加到工程文件中,步骤如下:
 
  (1)将这两个文件复制到工程所在的文件夹中。
 
  (2)在工程工作区选择“FileView”面板,右击“WndStyle files”。在弹出的快捷菜单中选择“Add Files to Project……”命令,然后在打开的“Add Files to Project”对话框双击要增加的文件。
 
  清单 AnimateIcon.cpp和AnimateIcon.h
 

 (AnimateIcon.cpp)
#include "stdafx.h"
#include "AnimateIcon.h"

// default constructor
CAnimateIcon::CAnimateIcon()
{
m_iImageCounter = -1;
m_iMaxNoOfImages = -99;
m_imgList.m_hImageList = NULL;
}

// 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;
}

 

[1]   

【责编:huangchunmei】

--------------------next---------------------

阅读(477) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~