zoukankan      html  css  js  c++  java
  • 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);
    // }
    // }
     

    效果图:

      

    完成 CImageList的类 高级空间
     




  • 相关阅读:
    AngularJS笔记---数据绑定
    Javascript笔记--函数
    C#笔记---动态类(Dynamic)应用
    Javascript笔记--Objects
    Javascript笔记----实现Page页面右下角置顶按钮.
    C#基础---扩展方法的应用
    .Net程序员之Python基础教程学习----函数和异常处理[Fifth Day]
    1.3 函数式接口
    1.2 lambda 表达式的语法
    1.1 为什么要使用lambda 表达式
  • 原文地址:https://www.cnblogs.com/xe2011/p/3885722.html
Copyright © 2011-2022 走看看