为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();

}

 

posted @ 2013-07-27 12:44  劃云  阅读(1056)  评论(0编辑  收藏  举报