class CDrawA : public CWnd
class CDrawB : public CDrawAvoid CDrawA::OnPaint()
{
  CPaintDC dc(this);
  int nMode = dc.SetBkMode(TRANSPARENT);
  dc.TextOut(0,0,"testDrawA");
  dc.SetBkMode(nMode);
}void CDrawB::OnPaint()
{
  CDrawA::OnPaint();  CPaintDC dc(this);
  int nMode = dc.SetBkMode(TRANSPARENT);
  dc.TextOut(50,0,"testDrawB");
  dc.SetBkMode(nMode);
}CDrawB* pdrawb = new CDrawB;
  pdrawb->Create(NULL, NULL, WS_CHILD | WS_VISIBLE |WS_BORDER,
  CRect(0,0,100,100), this, 11025);
  pdrawb->Invalidate();为什么只会显示testDrawA而testDrawB不显示?该如何改写,前提是不要在CDrawB中
dc.TextOut(0,0,"testDrawA");

解决方案 »

  1.   

    CView::OnDraw
    Called by the framework to render an image of the document. The framework calls this function to perform screen display, printing, and print preview, and it passes a different device context in each case. There is no default implementation.就是说frame处理界面的那些工作,包括显示,打印等,都在OnDraw这个函数中做处理,那你就按LS的做法,重写这个OnDraw,然后添加自己的操作就行。一定要B做处理,那就ondraw中调用B的处理函数就行了