!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

解决方案 »

  1.   

    SetTimer消息,OnTimer里调用InvalidateRect/Invalidate();OnPaint函数中绘制图形
      

  2.   

    别打酱油行不,发sinx函数咋用的代码看看
      

  3.   

    #define MAX_COUNT (1000)
    #define PI (3.14)
    POINT pt[2 * MAX_COUNT] = {0};int g_nStep = 0;
    const int STEP = 10;
    // CXXXXXDlg message handlersBOOL CXXXXXDlg::OnInitDialog()
    {
    CDialog::OnInitDialog();
            // ....
    CRect rect;
    GetClientRect(&rect); for(int i = 0; i < 2 * MAX_COUNT; i++)
    {
    pt[i].x = (int)(i * rect.Width() / MAX_COUNT);
    pt[i].y = (int) (rect.Height() * (1 - sin(2 * PI * i / MAX_COUNT)) / 2);
    }
    SetTimer(1, 500, NULL);
    return TRUE;  // return TRUE  unless you set the focus to a control
    }
    void CXXXXXDlg::OnTimer(UINT_PTR nIDEvent)
    {
    // TODO: Add your message handler code here and/or call default g_nStep= (g_nStep + STEP) % MAX_COUNT;
    InvalidateRect(NULL, TRUE); CDialog::OnTimer(nIDEvent);
    }
    void CXXXXXDlg::OnPaint()
    {
    CPaintDC dc(this); // device context for painting CRect rect;
    GetClientRect(&rect); SetViewportOrgEx(dc.GetSafeHdc(), -g_nStep * rect.Width() / MAX_COUNT, 0, NULL);
    dc.MoveTo(-g_nStep * rect.Width() / MAX_COUNT, rect.Height() / 2);
    dc.LineTo(rect.Width() + g_nStep * rect.Width() / MAX_COUNT, rect.Height() / 2);
    dc.Polyline(pt + g_nStep, MAX_COUNT) ;
    }