WM_PAINT添加消息处理函数
void CDialog6::OnPaint()
{
CPaintDC dc(this);// device context for painting
CRect rect;
GetClientRect(&rect);
CDC dcMem;
dcMem.CreateCompatibleDC(&dc);
CBitmap bmpBackground;
bmpBackground.LoadBitmap(IDB_BITMAP2); //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);
// Do not call CDialog::OnPaint() for painting messages
}
方法一:
在OnPaint中StretchBlt
具体是:注释掉CDialog::OnPaint()或放到结尾(原因何在呢?),并加入贴图代码
void CqqqqqDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKG