阅读:1418回复:0
OnDraw函数如何调用?急急急急!
我在做一个基于单文档的应用程序时遇到的情况:如下,想通过消息传递方式从CKeeTouch_DebugApp类发消息给CKeeTouch_DebugView类,调用CView类的OnDraw函数;
代码如下: //CKeeTouch_DebugApp类 void CKeeTouch_DebugApp::OnDrawX() { DebugView.WhichView=0; int k=DebugView.WhichView; ::PostMessage(DebugView.m_hWnd,WM_DRAWX, 0, 0); } //CKeeTouch_DebugView类 ON_MESSAGE(WM_DRAWX,Draw) void CKeeTouch_DebugView::Draw() { Invalidate();//程序每次走到这里就报错 UpdateWindow(); } void CKeeTouch_DebugView::OnDraw(CDC* pDC) { CDC MemDC; CBitmap MemBitmap; int nWidth=1024,nHeight=650; MemDC.CreateCompatibleDC(NULL); MemBitmap.CreateCompatibleBitmap(pDC,nWidth,nHeight); CBitmap *pOldBit=MemDC.SelectObject(&MemBitmap); MemDC.FillSolidRect(0,0,nWidth,nHeight,RGB(0,255,255)); pDC->BitBlt(0,0,nWidth,nHeight,&MemDC,0,0,SRCCOPY); MemBitmap.DeleteObject(); MemDC.DeleteDC(); } 程序才VC下编译是通过的,可惜运行的时候每次走到调用 Invalidate()函数就出错!请问是为什么?我改怎么改呀! |
|