C++ Code_ImageList
|
主题 |
|
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);
// }
//
} 效果图:
|
C++ Code_ImageList的更多相关文章
随机推荐
- 【LeetCode】242 - Valid Anagram
Given two strings s and t, write a function to determine if t is an anagram of s. For example,s = &q ...
- effective c++:资源管理
对象管理资源 createInvestment 函数作用时创建一个invest对象: void f() { Investment *pInv = createInvestment(); // call ...
- Protocol Buffer详解
1.Protocol Buffer 概念 Google Protocol Buffer( 简称 Protobuf) 是 Google 公司内部的混合语言数据标准,目前已经正在使用的有超过 48,162 ...
- SNMP 和 NetBios协议理解
一.简单网络管理协议(SNMP,Simple Network Management Protocol)构成了互联网工程工作小组(IETF,Internet Engineering Task For ...
- 网络爬虫系统Heritrix的结构分析 (个人读书报告)
摘要 随着网络时代的日新月异,人们对搜索引擎,网页的内容,大数据处理等问题有了更多的要求.如何从海量的互联网信息中选取最符合要求的信息成为了新的热点.在这种情况下,网络爬虫框架heritrix出现 ...
- Ajax禁止缓存的几个解决方案
最常用的方法是 方法1:服务器端代码加入 代码如下 复制代码 response.setHeader("Cache-Control", "no-cache, must-r ...
- CentOS下MySQL 5.7.9编译安装
MySQL 5.7 GA版本的发布,也就是说从现在开始5.7已经可以在生产环境中使用,有任何问题官方都将立刻修复. MySQL 5.7主要特性: 更好的性能:对于多核CPU.固态硬盘.锁有着更好的优化 ...
- Wisdombud.CommonTool及其应用
@(编程) 1. 用法 student类 using System.ComponentModel; namespace WindowsFormsApplication1 { public class ...
- ESP8266 TCP传输AT指令顺序
); //复位 ret = ESP8266_Cmd ( );//测试AT启动 ret = ESP8266_Cmd ( );//选择WIFI应用模式softAP+station //ret = ESP8 ...
- 将表A的数据复制到表B,以及关于主表和子表的删除办法
如果表A的数据结构和表B的数据结构是一样的,字段名字可以不用相同,但是对应的数据类型是一样的 这样的情况下可以用如下的方式实现将表A的数据复制到表B INSERT INTO #TEMP2 SELECT ...
