将图像插入到listcontrol中 [英] insert image in to listcontrol

查看:112
本文介绍了将图像插入到listcontrol中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在listcontrol mfc中插入图像(png,bmp,jpeg所有格式)。帮助我

How to insert images(png,bmp,jpeg all formats) in listcontrol mfc.Help me

推荐答案

列表控件通过分配<$ c $来支持图像c> CImageList 到列表控件。 CImageList 类支持位图和图标。要添加其他图像类型,必须先将它们转换为位图。要执行转换,请使用 CImage 类。



步骤如下:



  • CImageList 成员添加到窗口类(对话框,视图)或派生的 CListCtrl class。
  • 创建图像列表,调用 Create()指定最大值。图像大小,颜色深度和图像数量(对应于列表控制项的数量)。
  • 使用 CImage加载每个图像 class:
    • 使用<$ c从 CImage 创建 CBitmap 对象$ c> CBitmap :: Attach()传递 CImage :: Detach()返回的位图句柄。
    • 使用 Add()函数将 CBitmap 图像添加到图像列表中。
List controls support images by assigning a CImageList to the list control. The CImageList class supports bitmaps and icons. To add other image types, they must be converted first to bitmaps. To perform the conversion, use the CImage class.

The steps are:

  • Add a CImageList member to your window class (dialog, view) or your derived CListCtrl class.
  • Create the image list calling Create() specifying the max. size of the images, the color depth, and the number of images (corresponding to the number of list control items).
  • Load each image using the CImage class:
    • Create a CBitmap object from the CImage using CBitmap::Attach() passing the bitmap handle returned by CImage::Detach()..
    • Add the CBitmap image to the image list using the Add() function.


这篇关于将图像插入到listcontrol中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆