• MFC程序实现给对话框加入�背景图片


    1.插入一个Bitmap的资源图片,如果资源名称为:IDC_BITMAP1

    2.在CXXXDialog::OnPaint()中实现:

    void CMyDialogDlg::OnPaint()
    {
        if (IsIconic())
        {
            CPaintDC dc(this); // 用于绘制的设备上下文
    
            SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
    
            // 使图标在工作区矩形中居中
            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;
    
            // 绘制图标
            dc.DrawIcon(x, y, m_hIcon);
        }
        else
        {
            //
            // 给窗口加入�背景
            //
            CPaintDC dc(this);
            CRect rc;
            GetClientRect(&rc);
            CDC dcMem;
            dcMem.CreateCompatibleDC(&dc);
            CBitmap bmpBackground;
            bmpBackground.LoadBitmap(IDB_BITMAP1);
    
            BITMAP bitmap;
            bmpBackground.GetBitmap(&bitmap);
            CBitmap* pbmpPri = dcMem.SelectObject(&bmpBackground);
            dc.StretchBlt(0,0,rc.Width(), rc.Height(), &dcMem,0,0,bitmap.bmWidth, bitmap.bmHeight, SRCCOPY);
        }
    }


  • 相关阅读:
    ansible常用模块及参数(1)
    ansible搭建wordpress,安装nfs和rsync
    ElasticSearch 集群
    kibana数据操作
    ElasticSearch 交互使用
    Elasticsearch的基础安装
    Elasticsearch的简介
    redis数据审计
    redis数据迁移
    redis集群节点添加与删除
  • 原文地址:https://www.cnblogs.com/hrhguanli/p/3818112.html
Copyright © 2020-2023  润新知