一、资源视图添加BITMAP位图资源
二、#include “resource.h”
二、 在该对话框类视图中(或者类向导消息函数或者别的什么方法)找到OnPaint函数,在else{后添加代码;
CBitmap bmp;
bmp.LoadBitmap(IDB_BITMAP1); //载入位图
int nBmpWidth, nBmpHeight;
BITMAP bmInfo;
bmp.GetBitmap(&bmInfo);
nBmpWidth=bmInfo.bmWidth;
nBmpHeight=bmInfo.bmHeight; //获取位图的实际大小
CRect clientRC;
GetClientRect(clientRC); //获取客户区域的大小
CDC *pDC=GetDC(); //屏幕DC
CDC memDC;
memDC.CreateCompatibleDC(pDC); //内存DC
memDC.SelectObject(&bmp);
pDC->StretchBlt(0,0,clientRC.Width(),clientRC.Height(),&memDC,0,0, nBmpWidth, nBmpHeight, SRCCOPY); //在窗口绘图
memDC.DeleteDC();
bmp.DeleteObject();
ReleaseDC(pDC);//释放
bmp.LoadBitmap(IDB_BITMAP1); //载入位图
int nBmpWidth, nBmpHeight;
BITMAP bmInfo;
bmp.GetBitmap(&bmInfo);
nBmpWidth=bmInfo.bmWidth;
nBmpHeight=bmInfo.bmHeight; //获取位图的实际大小
CRect clientRC;
GetClientRect(clientRC); //获取客户区域的大小
CDC *pDC=GetDC(); //屏幕DC
CDC memDC;
memDC.CreateCompatibleDC(pDC); //内存DC
memDC.SelectObject(&bmp);
pDC->StretchBlt(0,0,clientRC.Width(),clientRC.Height(),&memDC,0,0, nBmpWidth, nBmpHeight, SRCCOPY); //在窗口绘图
memDC.DeleteDC();
bmp.DeleteObject();
ReleaseDC(pDC);//释放