1.导入图片到资源IDB_BITMAP1
2.在OnInitDialog()函数中加入:
CRgn wndRgn,rgnTemp;
wndRgn.CreateEllipticRgn(0,0,480,300);
SetWindowRgn((HRGN)wndRgn,true);
3.在OnPaint() 函数中的else中加入:
CPaintDC dc(this);
CRect rect;
GetWindowRect(&rect);
CDC memDC;
CBitmap cBitmap;
CBitmap* pOldMemBmp=NULL;
cBitmap.LoadBitmap(IDB_BITMAP1);
memDC.CreateCompatibleDC(&dc);
pOldMemBmp=memDC.SelectObject(&cBitmap);
dc.BitBlt(0,0,rect.Width(),rect.Height(),&memDC,0,0,SRCCOPY);
if(pOldMemBmp)memDC.SelectObject(pOldMemBmp);
CDialog::OnPaint();
4.添加左键响应函数,使其能被拖动:
void CEllipsefaceDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
::SendMessage(this->GetSafeHwnd(),WM_SYSCOMMAND,SC_MOVE+2,0);
CDialog::OnLButtonDown(nFlags, point);
}