绘图控件使用双缓冲后,为什么在word中看来就成一片黑了?

yuanting2006 2009-09-14 02:27:52
这是原码,请各位帮忙解决啊!
void CTestCtrl::OnDraw(
CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)
{

int nWidth,nHeight;
nHeight=rcBounds.Height();
nWidth=rcBounds.Width();
CDC MemDC;
CBitmap MemBitmap
MemDC.CreateCompatibleDC(NULL);
MemBitmap.CreateCompatibleBitmap(pdc,nWidth,nHeight);

CBitmap *pOldBit=MemDC.SelectObject(&MemBitmap);
MemDC.FillSolidRect(0,0,nWidth,nHeight,RGB(255,255,255));
//绘图
MemDC.MoveTo(0,0);
MemDC.LineTo(nWidth,nHeight);

pdc->BitBlt(0,0,nWidth,nHeight,&MemDC,0,0,SRCCOPY);

MemBitmap.DeleteObject();
MemDC.DeleteDC();


}
...全文
198 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
leifugui 2009-09-15
  • 打赏
  • 举报
回复
不好意思,我这只是一个mark.此软件跟word没关系,是能在很多操作系统上运行的软件.
yuanting2006 2009-09-15
  • 打赏
  • 举报
回复
什么意思?需要用这个软件再进行一下改动吗?
leifugui 2009-09-15
  • 打赏
  • 举报
回复
word为了安全把你的东西灭了.需要改进

看这个

yuanting2006 2009-09-15
  • 打赏
  • 举报
回复
那请问应该怎样创建双缓冲呢?我从网上找的好些都是这样写的.不知道那个地方有问题啊?
Qt-UI 2009-09-15
  • 打赏
  • 举报
回复
应该你新建的缓冲用CDC未起到作用 可能创建不正确 帮顶一下
yuanting2006 2009-09-15
  • 打赏
  • 举报
回复
没有人遇到这种情况吗?高手帮忙啊!
lichao20072613 2009-09-14
  • 打赏
  • 举报
回复
CBitmap MemBitmap少了个分号。
yuanting2006 2009-09-14
  • 打赏
  • 举报
回复
如果这样写MemDC.CreateCompatibleDC(pDC);

在word中引用控件后,会提示Debug Assertion Failed!
program:d:\Program files\microsoft office\office11\winword.exe
file:afxwin1.inl
lint:558

for information on how your program can cause an assertion failure,see the visual c++ documentation on asserts.

(press retry to debug the application)
dirdirdir3 2009-09-14
  • 打赏
  • 举报
回复
MemDC.CreateCompatibleDC(NULL);
?????????????
应该是
MemDC.CreateCompatibleDC(pDC);
yuanting2006 2009-09-14
  • 打赏
  • 举报
回复
请问怎么存呢?
o_yale_o 2009-09-14
  • 打赏
  • 举报
回复
你把CBitmap保存成文件看看

19,468

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 图形处理/算法
社区管理员
  • 图形处理/算法社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧