请教大家,我要在CFormView视图中加入背景图片,现在的问题是图片已经可以添加了,但是,我的CFormView中有一些其他的控件,所以,
当把CFormView拖动到比较小的时候,视图就会出现滚动条,然后拖动滚动条,结果视图里面的背景图片就出现了许多条纹,视图变的很模糊,
非常的难看。请教大家如何解决。
我是在OnPaint中添加的背景图片:void CTest_FormView_BGView::OnPaint()
{
CPaintDC dcPaint(this); // device context for painting
// TODO: Add your message handler code here
CRect r;
GetClientRect(&r);
// Paint to a memory device context to help
// eliminate screen flicker.
CXTPBufferDC memDC(dcPaint, r);
memDC.FillSolidRect(r,GetSysColor(COLOR_WINDOW));
OnPrepareDC(&memDC);
OnDraw(&memDC); // Do not call CFormView::OnPaint() for painting messages
}
void CTest_FormView_BGView::OnDraw(CDC* pDC)
{
// TODO: Add your specialized code here and/or call the base class
CBitmap bmpStartPage;
if(!bmpStartPage.LoadBitmap(IDB_BITMAP1))//resource id
{
return;
}
CDC dcCompatible;
if (!dcCompatible.CreateCompatibleDC(pDC))
{
return;
}
CBitmap* pOld = dcCompatible.SelectObject(&bmpStartPage);
BITMAP bmInfo;
if(bmpStartPage.GetObject(sizeof(bmInfo),&bmInfo) != 0)
{
pDC->BitBlt(0,0,bmInfo.bmWidth,bmInfo.bmHeight,&dcCompatible,0,0,SRCCOPY);
}
dcCompatible.SelectObject(pOld);
}
当把CFormView拖动到比较小的时候,视图就会出现滚动条,然后拖动滚动条,结果视图里面的背景图片就出现了许多条纹,视图变的很模糊,
非常的难看。请教大家如何解决。
我是在OnPaint中添加的背景图片:void CTest_FormView_BGView::OnPaint()
{
CPaintDC dcPaint(this); // device context for painting
// TODO: Add your message handler code here
CRect r;
GetClientRect(&r);
// Paint to a memory device context to help
// eliminate screen flicker.
CXTPBufferDC memDC(dcPaint, r);
memDC.FillSolidRect(r,GetSysColor(COLOR_WINDOW));
OnPrepareDC(&memDC);
OnDraw(&memDC); // Do not call CFormView::OnPaint() for painting messages
}
void CTest_FormView_BGView::OnDraw(CDC* pDC)
{
// TODO: Add your specialized code here and/or call the base class
CBitmap bmpStartPage;
if(!bmpStartPage.LoadBitmap(IDB_BITMAP1))//resource id
{
return;
}
CDC dcCompatible;
if (!dcCompatible.CreateCompatibleDC(pDC))
{
return;
}
CBitmap* pOld = dcCompatible.SelectObject(&bmpStartPage);
BITMAP bmInfo;
if(bmpStartPage.GetObject(sizeof(bmInfo),&bmInfo) != 0)
{
pDC->BitBlt(0,0,bmInfo.bmWidth,bmInfo.bmHeight,&dcCompatible,0,0,SRCCOPY);
}
dcCompatible.SelectObject(pOld);
}
解决方案 »
- com进程外组件的rpc机制是怎么实现的
- 线程函数传递的问题
- 急!急!急! 如何在用InstallShield 打包安装程序时让安装程序自动注册"数据源"
- VC++
- 请问 : 在线程1中的dll里如何给主线程的一个对话框发送消息?
- ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
- -------->我要編一個像QQ一樣的能夠語音通話的聊天軟件,請問,需要那些技術及協議??
- MFC中获取分割视区指针问题?
- 串口发送文件疑问
- 打印时出现乱码,在有些打印机上不会,有高分相送的哈
- 如何读取RES文件
- 此程序为什么不能访问成员变量(我最痛苦的就是编译正常,调试不出来什么东西,却运行不正常)
采用了“在OnEraseBkgnd()中绘制背景图”,基本采用的原来的代码,只是换成了在OnEraseBkgnd()中添加图片,由滚动条产生的问题解决了,但是又出现了
新的问题,就是当拖动CFormView的的大小超过图片大小的时候,在视图的边缘又出现了条纹和模糊的界面。请教如何解决这个问题。
Invalidate(TRUE).
然后再把土贴上
你的方法我试过了,当拖动CFormView的的大小超过图片大小的时候,边缘仍然模糊!