MFC高级控件之 图像列表控件

本文详细介绍了Windows编程中CImageList类的使用,包括Create方法的各种参数及其意义,以及如何通过CImageList创建和操作图像列表。通过一个实例展示了如何在对话框程序中创建工具栏并设置图标,通过改变Create方法参数观察图像列表效果。

图像列表控价与其它控件不同,不能从工具箱的控件面板添加到程序界面中。图像列表控件是一个类:CImageList。要使用该控件,需通过编辑代码实现。该控件用以存储大小相同的一组图像。常使用图像列表控件来为工具条、树状控件、列表控价等的内容设置图标。当然也用可以图像列表将图像绘制到程序中。本文将详细介绍图像列表控件,并以一个实例演示如何使用图像列表。

创建图像列表是通过Create方法,MSDN中对Create方法做了详细说明,列出了一下几个终止函数:

BOOL Create( int cx, int cy, UINT nFlags, int nInitial, int nGrow );

BOOL Create( UINT nBitmapID, int cx, int nGrow, COLORREF crMask );

BOOL Create( LPCTSTR lpszBitmapID, int cx, int nGrow, COLORREF crMask );

BOOL Create( CImageList& imagelist1, int nImage1, CImageList& imagelist2, int nImage2, int dx, int dy );

BOOL Create( CImageList* pImageList );

如果生成图像列表成功返回非零值,否则返回值为零。MSDN中对函数参数做了如下说明:

Parameters

cx

Dimensions of each image, in pixels.

cy

Dimensions of each image, in pixels.

nFlags

Specifies the type of image list to create. This parameter can be a combination of the following values, but it can include only one of the ILC_COLOR values.

Value Meaning
ILC_COLOR Use the default behavior if none of the other ILC_COLOR* flags is specified. Typically, the default is ILC_COLOR4; but for older display drivers, the default is ILC_COLORDDB.
ILC_COLOR4 Use a 4-bit (16 color) device-independent bitmap (DIB) section as the bitmap for the image list.
ILC_COLOR8 Use an 8-bit DIB section. The colors used for the color table are the same colors as the halftone palette.
ILC_COLOR16 Use a 16-bit (32/64k color) DIB section.
ILC_COLOR24
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Bill66

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值