急啊,大侠救命啊,能解决问题的立刻给分
问题是这样的,动态创建的窗口刷新时总是留有背景,
即重画时不清除原有绘制的内容,这样前面和后面画的东西都叠在一起
如何解决?
代码如下:
void CMainFrame::OnOperatorBegin()
{
    // TODO: Add your command handler code here
    mwnd.CreateEx(0, AfxRegisterWndClass(0,NULL,NULL,NULL),  L"DnWnd", WS_POPUP
| WS_VISIBLE |WS_OVERLAPPEDWINDOW,
        CRect(100,100,500,500),this, 0);
}void MyWnd::OnPaint()
{
    CPaintDC dc(this); // device context for painting
    // TODO: Add your message handler code here
    // Do not call CWnd::OnPaint() for painting messages
    dc.MoveTo(20,20);
    dc.LineTo(220,220);
}其中mwnd是CMainFrame中的一个MyWnd对象,而MyWnd是继承自CWnd

解决方案 »

  1.   

    创建好以后用UpdateWindow重绘一下
      

  2.   

    在View里面创建,mwnd申明为View成员。
    试试。
      

  3.   

    看错了,你应该从CDialog派生MyWnd吧?
      

  4.   

    在View里面创建,mwnd申明为View成员。
    试试。----------------还是一样,不行MyWnd是派生自CWnd
      

  5.   

    m_mywnd.CreateEx(NULL, AfxRegisterWndClass(0,NULL,
    (HBRUSH) ::GetStockObject(WHITE_BRUSH),NULL),  //if pass null, do not erase background
    "My Window", WS_POPUP| WS_VISIBLE |WS_OVERLAPPEDWINDOW, CRect(100,100,500,500),this, 0);
    看看这个是你要的效果?
      

  6.   

    谢谢大家,我已经搞定了
    m_mywnd.CreateEx(NULL, AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW , NULL,
    (HBRUSH) ::GetStockObject(WHITE_BRUSH),NULL), //if pass null, do not erase background
    "My Window", WS_POPUP| WS_VISIBLE |WS_OVERLAPPEDWINDOW, CRect(100,100,500,500),this, 0);这样就对了