int i=0;
CString temp;
while(i<10)
{
   temp+="a";
   m_prompt.SetWindowText(temp);//为什么要等循环结束才能显示?
   
  m_sql=temp;//用变量与控件相连也不行
   UpdateData(false);
   i++;
}
//如何才能让CEdit能循环显示内容?谢谢

解决方案 »

  1.   

    int i=0;
    CString temp;
    while(i<10)
    {
       temp+="a";
       m_prompt.SetWindowText(temp);//为什么要等循环结束才能显示?
       
      m_sql=temp;//用变量与控件相连也不行
       UpdateData(false);
       PeekAndPump();
       i++;
    }
    BOOL PeekAndPump()
    {
     static MSG msg; while (::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE)) {
      if (!AfxGetApp()->PumpMessage()) {
       ::PostQuitMessage(0);
       return FALSE;
      } 
     }
     return TRUE;
    }
      

  2.   

    int i=0;
    CString temp;
    while(i<10)
    {
       temp+="a";
       m_prompt.SetWindowText(temp);
       ::UpdateWindow(GetSafeHwnd())//try this one   Sleep(1); //可能刷新得太快,阻塞一下
       i++;
    }
      

  3.   

    UpdateWindow后面少了个分号,不好意思
      

  4.   

    Windows不停的会收到各种消息,而消息的优先度不同,在消息队列中等待的时间也会不同。上面的做法无非就是让Windows立即处理消息而已
      

  5.   

    按照yemingwy(小新)和 pomelowu(羽战士)  改动了程序还是没有用,各位再帮忙看看,谢谢!
      

  6.   

    int i=0;
    CString temp;
    MSG msg;
    while(i<10)
    {
    temp+="a";
    // m_prompt.SetWindowText(temp);//为什么要等循环结束才能显示?

    m_sql=temp;//用变量与控件相连也不行
    UpdateData(false);
    Sleep(100); while(PeekMessage(&msg,NULL,0,0,PM_REMOVE))
    {
    TranslateMessage(&msg);
    DispatchMessage(&msg);
    }
    i++;
    }经过测试可行~
      

  7.   

    我的代码没问题,只不过Sleep的间隔太小了,所以看不到效果。int i=0;
    CString temp;
    while(i<10)
    {
       temp+="a";
       m_prompt.SetWindowText(temp);
       //::UpdateWindow(GetSafeHwnd())
       // 实际上只要用Sleep等待消息被处理即可,连UpdateWindow都可以不用   Sleep(100); //可能刷新得太快,阻塞一下
       i++;
    }