对话框不同情况下切换背景图片,就是两个类公用一个对话框,只是背景图片不一样;

void DLGDeleteEnter::OnPaint()
{
CPaintDC dc(this); // device context for painting
CDC memdc;
memdc.CreateCompatibleDC(&dc);//创建兼容DC

CBitmap bkg;
if ( m_IsDeleteSign == TRUE )
{
bkg.LoadBitmap( IDB_BITMAP_SignDELETEDLG );//载入位图
}
if ( m_IsDeleteSign == FALSE )
{
bkg.LoadBitmap(IDB_BITMAP_MESSAGEDLGDELETE );//载入位图
}

BITMAP bkginfo;
bkg.GetBitmap(&bkginfo);//获取位图信息

memdc.SelectObject(&bkg);

RECT rect;
GetWindowRect(&rect);//获取对话框信息

dc.StretchBlt(0,0,rect.right-rect.left,rect.bottom-rect.top,&memdc,0,0,bkginfo.bmWidth,bkginfo.bmHeight,SRCCOPY);

posted @ 2013-06-04 11:53  友琼  阅读(126)  评论(0编辑  收藏  举报