MFC添加背景图片

1.在资源里导入一个bmp图片假设名称为IDB_BITMAP1

实现OnPaint方法

    CPaintDC dc(this); 
    CRect   rect;   
    GetClientRect(&rect);   
    CDC   dcMem;   
    dcMem.CreateCompatibleDC(&dc);   
    CBitmap   bmpBackground;   
    bmpBackground.LoadBitmap(IDB_BITMAP1);   
            //IDB_BITMAP是你自己的图对应的ID   
    BITMAP   bitmap;   
    bmpBackground.GetBitmap(&bitmap);   
    CBitmap   *pbmpOld=dcMem.SelectObject(&bmpBackground);   
    dc.StretchBlt(0,0,rect.Width(),rect.Height(),&dcMem,0,0,   
    bitmap.bmWidth,bitmap.bmHeight,SRCCOPY);  

原文地址:https://www.cnblogs.com/li-peng/p/3777534.html