博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

MFC实现窗口抖动

Posted on 2009-02-25 15:07  Tom Wu  阅读(867)  评论(0)    收藏  举报

int ty=5;
 CRect   m_rect;  
 GetWindowRect(&m_rect); 
 int recordy=m_rect.left;
 int recordx=m_rect.top;

for(int i=0;i<3;i++)
 {
    m_rect.left=recordy;
    m_rect.top=recordx;
    m_rect.top = m_rect.top + ty; 
    m_rect.left = m_rect.left - ty;
    SetWindowPos( NULL,m_rect.left,m_rect.top,0,0,SWP_NOSIZE );Sleep(35);
    m_rect.top = m_rect.top -ty;
    SetWindowPos( NULL,m_rect.left,m_rect.top,0,0,SWP_NOSIZE );Sleep(35);
    m_rect.top = m_rect.top -2*ty;
    SetWindowPos( NULL,m_rect.left,m_rect.top,0,0,SWP_NOSIZE );Sleep(35);
    m_rect.left=m_rect.left+ty;
    SetWindowPos( NULL,m_rect.left,m_rect.top,0,0,SWP_NOSIZE );Sleep(35);
    m_rect.left=m_rect.left+2*ty;
    SetWindowPos( NULL,m_rect.left,m_rect.top,0,0,SWP_NOSIZE );Sleep(35);
    m_rect.top = m_rect.top + ty; 
    SetWindowPos( NULL,m_rect.left,m_rect.top,0,0,SWP_NOSIZE );Sleep(35);
    m_rect.top=m_rect.top+2*ty;
    SetWindowPos( NULL,m_rect.left,m_rect.top,0,0,SWP_NOSIZE );
    SetWindowPos( NULL,recordy,recordx,0,0,SWP_NOSIZE );
    Sleep(35);