设置一个Timer,然后用SetWindowPos就可以了

解决方案 »

  1.   

    谢谢,在一个SDI程序中,重载了OnShowWindow()函数,在其中SetTimer(1,10,NULL);窗口能移动了。
    我在CMyView::OnDraw()中,Textout(0,0,"Hello world!");想在窗口停止时才显示出来,如何操作!还有窗口如何停止!!!
    若我想移动一个Dialog,该在何处调用SetTimer();我一定会加分的!!!
      

  2.   

    这是我以前写的一段代码,实现像OICQ那样自动隐藏的效果。你可以参考一下。
    Init()在OnInitDialog中调用。void CTempDlg::Init()
    {
    int nPixesOK,nPixesCancel,nScreenHeight,nBorder;
    POINT point;
    CRect rectDlg,rectBtn;
    nBorder=GetSystemMetrics(SM_CYBORDER);
    nScreenHeight=GetSystemMetrics(SM_CYSCREEN);
    GetWindowRect(rectDlg);
    m_btnCancel.GetWindowRect(rectBtn);
    nPixesCancel=rectDlg.bottom-rectBtn.top;
    m_btnOK.GetWindowRect(rectBtn);
    nPixesOK=rectDlg.bottom-rectBtn.top;
    SetWindowPos(&wndTopMost,0,0,rectDlg.Width(),nScreenHeight,0);
    GetWindowRect(rectDlg);
    m_btnOK.MoveWindow(rectBtn.left,rectDlg.bottom-nPixesOK-20,rectBtn.Width(),rectBtn.Height());
    m_btnCancel.MoveWindow(rectBtn.left,rectDlg.bottom-nPixesCancel-20,rectBtn.Width(),rectBtn.Height());
    m_nHideX=2-rectDlg.Width();
    SetTimer(IDT_CHECK,10,NULL);
    }void CTempDlg::OnOK() 
    {
    // TODO: Add extra validation here
    }void CTempDlg::OnTimer(UINT nIDEvent) 
    {
    // TODO: Add your message handler code here and/or call default
    CRect rect;
    GetWindowRect(rect);
    if(nIDEvent==IDT_ANIMATE)
    {
    if(m_bIsHide)
    {
    rect.OffsetRect(m_nSpeed,0);
    if(rect.left>=m_nShowX)
    {
    rect.OffsetRect(m_nShowX-rect.left,0);
    m_bIsHide=false;
    KillTimer(IDT_ANIMATE);
    }
    MoveWindow(rect);
    }
    else
    {
    rect.OffsetRect(-m_nSpeed,0);
    if(rect.left<=m_nHideX)
    {
    rect.OffsetRect(m_nHideX-rect.left,0);
    m_bIsHide=true;
    KillTimer(IDT_ANIMATE);
    }
    MoveWindow(rect);
    }
    }
    if(nIDEvent==IDT_CHECK)
    {
    POINT point;
    GetCursorPos(&point);
    if(rect.PtInRect(point)==TRUE && m_bIsHide==true)
    {
    m_bIsHide=false;
    AnimateShow();
    }
    else if(rect.PtInRect(point)==FALSE && m_bIsHide==false)
    {
    m_bIsHide=true;
    AnimateHide();
    }
    }
    CDialog::OnTimer(nIDEvent);
    }void CTempDlg::AnimateHide()
    {
    m_bIsHide=false;
    SetTimer(IDT_ANIMATE,5,NULL);
    }void CTempDlg::AnimateShow()
    {
    m_bIsHide=true;
    SetTimer(IDT_ANIMATE,5,NULL);
    }
      

  3.   

    <h1>AnimateWindow</h1>The <font color=red>AnimateWindow </font>function enables you to produce special effects when showing or hiding windows. There are two types of animation: <big>roll animation and slide animation. </big>BOOL AnimateWindow(
      HWND hwnd,     // handle to the window to animate
      DWORD dwTime,  // duration of animation
      DWORD dwFlags  // animation type
    );
     
      

  4.   

    AnimateWindow()这个函数不支持!