为MFC按钮添加各种图片

一般放在重绘函数OnPaint()里

 OnPaint()

{

       //为按钮添加图片

        Image image(L"...resSH\退出系统正常状态.png",TRUE);
        Graphics graphics(m_button16.GetWindowDC()->m_hDC);
        graphics.DrawImage(&image,0,0,image.GetWidth(),image.GetHeight());

         //为窗体添机背景图片

         CPaintDC dc(this); // device context for painting

         CRect rect;

         GetClientRect(&rect);
         Graphics graphics(dc.m_hDC);
         //加载PNG图片
         Bitmap background(L".\userlist\classlist_top.png");
         graphics.DrawImage(&background,0,0,rect.Width(),rect.Height());
         CDialog::OnPaint();

}

原文地址:https://www.cnblogs.com/zys871841072/p/3219299.html