主题

1.  创建图像列表

2.  使用图像列表绘图

3.

4.

5.

 
 

代码::创建图像列表

双击 Cproject03Dlg在
    下面添加 1 句
/////////////////////////////////////////////////////////////////////////////
// CProject01Dlg dialog
// class CProject01Dlg : public
CDialog
// {
// Construction
// public:
// CProject01Dlg(CWnd* pParent = NULL);
// standard constructor
    CImageList m_ImgLst;
 
手动在资源编辑器中添加 3 个Icon资源
 
双击 OnInitDialog()在  
// TODO: Add extra initialization here
添加如下代码
 
// TODO: Add extra initialization
here
m_ImgLst.Create( 32
, 32 ,ILC_COLOR24 | ILC_MASK, 1 , 0 );
m_ImgLst.Add( LoadIcon(AfxGetResourceHandle(),MAKEINTRESOURCE(IDI_ICON1)) );
m_ImgLst.Add( LoadIcon(AfxGetResourceHandle(),MAKEINTRESOURCE(IDI_ICON2)) );

m_ImgLst.Add( LoadIcon(AfxGetResourceHandle(),MAKEINTRESOURCE(IDI_ICON3)) );

 
 
使用图像列表绘图
 
CImageList m_ImgLst;
双击OnPaint()添加如下代码
 
//void
CProject01Dlg::OnPaint()
//{
// if (IsIconic())
// {
// CPaintDC dc(this); // device context
for painting
//
// SendMessage(WM_ICONERASEBKGND,
(WPARAM) dc.GetSafeHdc(), 0);
//
// // Center icon in client
rectangle
// int cxIcon =
GetSystemMetrics(SM_CXICON);
// int cyIcon =
GetSystemMetrics(SM_CYICON);
// CRect rect;
//
GetClientRect(&rect);
// int x = (rect.Width() - cxIcon + 1) /
2;
// int y = (rect.Height() - cyIcon + 1)
/ 2;
//
// // Draw the icon
// dc.DrawIcon(x, y,
m_hIcon);
// }
// else
// {
// CDialog::OnPaint();
        CDC
* pDC = GetDC();
        CPoint
pt;
        pt.x = 30 ;
        pt.y = 50 ;
        for
( int i = 0 ;i < 3 ;i ++ )
        {
            pt.x += 60 ;
            m_ImgLst.Draw(pDC,i,pt,ILD_NORMAL);
        }
        ReleaseDC(pDC);
// }
//
}

效果图:

完成 CImageList的类 高级空间
 

C++ Code_ImageList的更多相关文章

随机推荐

  1. VMware 命令行下安装以及导入Ubuntu系统

    前提: 鉴于个人PC性能太弱,考虑是否可以将在PC上搭建好的环境移植到高性能服务器上.想到后就干呗. 下载完对应操作系统的安装包后按如下步骤操作: 安装包名称:VMware-Workstation-F ...

  2. nginx指令

    Directives(指令) Syntax(语法): aio on | off | threads[=pool]; Default: aio off; Context: http, server, l ...

  3. 《Java数据结构与算法》笔记-CH5-链表-1单链表

    /** * Link节点 * 有数据项和next指向下一个Link引用 */ class Link { private int iData;//数据 private double dData;//数据 ...

  4. 去掉StringBuilder或String 最后一个项逗号

    一. sb.Length = sb.Length - 1; 二. stringBuilder.Remove(stringBuilder.ToString().LastIndexOf(','), 1); ...

  5. T-SQL 运行时生成语句

    运行时生成语句 1.用EXECUTE执行动态命令 EXECUTE命令可以执行存储过程.函数和动态的字符串命令.注意此语句的作用正如前面在介绍批处理时,如果批中的第一条语句是"EXECUTE存 ...

  6. NLP初步

    [NLP初步] NLP是Natural Lanuage Process的缩写.搜索引擎可以通过关词匹配和完成很多的任务, 比如话题搜索(搜索包含律师, 法院, 控告等词的文档), 但是搜索引擎无法理解 ...

  7. POJ 1066 Treasure Hunt(线段相交判断)

    Treasure Hunt Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4797   Accepted: 1998 Des ...

  8. Windows 2003 服务器安全设置-批处理 (附参考链接)

    长期维护windows服务器终结出来的安全设置批处理与大家分享,复制以下全部内容用记事本另存为bat或者cmd执行 ===================分隔符号=================== ...

  9. c# 调用zebra打印指令 打印到USB端口

    c# 调用zebra打印机指令打印条码,如果直接打印到lpt1端口的打印机,通过copy指令没有问题, 但如果ZEBRA打印机是通过USB连接,打印机端口为usb001,则程序不能直接拷贝到usb00 ...

  10. CString的GetBuffer用法,GetBuffer本质,GetBuffer常见问题解决方法

    一.函数原型 CString::GetBuffer LPTSTR GetBuffer( int nMinBufLength ); throw( CMemoryException ); Return V ...