注册 登录
编程论坛 VC++/MFC

求助:CTableView::OnDraw()

chenbofeng20 发布于 2013-03-06 15:11, 542 次点击
class CTableView : public CTabView

 CTableView::OnDraw(CDC* pDC)
{
    CBitmap bitmap;
    bitmap.LoadBitmap(IDD_BG);
    CDC MenDC;
    MenDC.CreateCompatibleDC(pDC);
    MenDC.SelectObject()&bitmap;
    CRect rect;
    GetClientRect(rect);
    pDc->BitBlt(0,0,rect.Width(),rect.Heigh(),&MenDC,0,0,SRCCOPT);
    MenDC.DeleteDC();
}
我想实现在在Tab的视图区域的背景为一个图片,但是没有效果,求大神帮助!
4 回复
#2
yuccn2013-03-06 17:02
设置些调试信息,看下每一步是否有成功。

最好也吧窗口大小信息(rect.Width(),rect.Heigh())也打印出来看看
#3
信箱有效2013-03-06 23:45
学习
#4
qunxingw2013-03-11 20:05
是否图像合成类似,
void CCombineImageDLG::OnOK()
{
}
#5
lileimt2013-03-13 15:53
CDC MemDC;
CBitmap MemBitmap;
MemDC.CreateCompatibleDC(NULL);
MemBitmap.CreateCompatibleBitmap(pDC,rect.Width(),rect.Height());
CBitmap *pOldBit=MemDC.SelectObject(&MemBitmap);
MemDC.FillSolidRect(0,0,rect.Width(),rect.Height(),RGB(255,255,255));

CDC dcCompatible;
CBitmap bmp;
BITMAP bmpInfo;
bmp.LoadBitmap(IDB_BITMAP_BKMAP);
bmp.GetBitmap(&bmpInfo);
dcCompatible.CreateCompatibleDC(&MemDC);
HBITMAP OldBitmap = (HBITMAP)dcCompatible.SelectObject(&bmp);
MemDC.StretchBlt(0,0,rect.Width(),rect.Height(),&dcCompatible,0,0,bmpInfo.bmWidth,bmpInfo.bmHeight,SRCCOPY);      
dcCompatible.SelectObject(&OldBitmap);

pDC->BitBlt(0,0,rect.Width(),rect.Height(),&MemDC, 0, 0, SRCCOPY);
MemBitmap.DeleteObject();
MemDC.DeleteDC();
1