制做像QQ那种自动停靠.自动收缩的窗口.[1]

[入库:2005年8月19日] [更新:2007年3月24日]

本文简介:选择自 hxblvc 的 blog

1.首先处理自动停靠.
    1).建立一个对话框类cdlg.
    2).
        ///dlg.h
          class cdlg
        {
            private:
                   bool m_isautohide; //窗口是否可以自动隐藏
                   bool m_iswinhide; // 窗口是否隐藏
               ...........
        }

      ///dlg.cpp
         .....
    void cdlg::onmove(int x, int y)
    {
         cdialog::onmove(x, y);
         
         ///窗口从显示到隐藏时,不做其它操作
        if(m_iswinhide)
         {
              return;
         }
         
         crect trect;
         getwindowrect(trect);
         if(trect.top<10)
         {///如果窗口移动后的位置和到屏幕上方的距离小于10
           ///就使窗口停靠到屏幕上方.

              trect.bottom-= trect.top;
              trect.top= 0;
              movewindow(trect);
               ///窗口停靠后就可以自动隐藏
              m_isautohide= true;
          }
         else
         {
               ///如窗口没有停靠就不可以自动隐藏
              m_isautohide= false;
         }
 
       }

    void cdlg::onmoving(uint fwside, lprect prect)
    {
        if((prect->top < 10)
          && (!m_isautohide) )
        {///如果窗口移动到的位置和到屏幕上方的距离小于10
           ///就使窗口停靠到屏幕上方.

                prect->bottom-= prect->top;
                prect->top= 0;
                m_isautohide= true;
        }

        cdialog::onmoving(fwside, prect);
    }
2.处理自动收缩
      //dlg.h
        class cdlg
         {
                .....
                lresult  onmouseleave( hwnd hwnd, uint msg,
                                              wparam  wparam,lparam lparam  );
         }

     //dlg.cpp
            begin_message_map(cdlg, cdialog)

本文关键:制做像QQ那种自动停靠.自动收缩的窗口.
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top