制做像QQ那种自动停靠.自动收缩的窗口,好东西呀,收藏起来,方便以后使用。谢谢了。
2004-10-01 11:42
726 查看
制做像QQ那种自动停靠.自动收缩的窗口.
(转自: http://blog.csdn.net/hxblvc/archive/2004/09/30/122057.aspx 我想使用TrackBacks试试)
1.首先处理自动停靠.
1).建立一个对话框类CDlg.
2).
///dlg.h
class CDlg
{
private:
bool m_isAutoHide; //窗口是否可以自动隐藏
bool m_isWinHide; // 窗口是否隐藏
...........
}
///dlg.cpp
.....
4000
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)
ON_MESSAGE(WM_MOUSELEAVE,OnMouseLeave)
END_MESSAGE_MAP()
.......
LRESULT CDlg::OnMouseLeave(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
if(m_isAutoHide)
{
CPoint tPoint;
GetCursorPos(&tPoint);
CRect tRect;
GetWindowRect(&tRect);
if(!(tRect.PtInRect(tPoint)))
{
m_isWinHide=true;
tRect.top= tRect.top - tRect.bottom +5;
tRect.bottom= 5;
MoveWindow(tRect);
::SetWindowPos(
::GetDesktopWindow()
,HWND_TOPMOST,tRect.left,tRect.top
,tRect.Width(),tRect.Height ()
,SWP_SHOWWINDOW);
}
}
return TRUE;
}
void CDlg::OnMouseMove(UINT nFlags, CPoint point)
{
if(m_isWinHide)
{
CRect tRect;
GetWindowRect(&tRect);
tRect.bottom+= (tRect.bottom-tRect.top-5);
tRect.top=0;
MoveWindow(tRect);
m_isWinHide= false;
}
TRACKMOUSEEVENT EventTrack;
EventTrack.cbSize= sizeof(TRACKMOUSEEVENT);
EventTrack.dwFlags= TME_LEAVE;
EventTrack.hwndTrack= this->m_hWnd;
_TrackMouseEvent(&EventTrack);
CDialog::OnMouseMove(nFlags, point);
}
<完成>
(转自: http://blog.csdn.net/hxblvc/archive/2004/09/30/122057.aspx 我想使用TrackBacks试试)
1.首先处理自动停靠.
1).建立一个对话框类CDlg.
2).
///dlg.h
class CDlg
{
private:
bool m_isAutoHide; //窗口是否可以自动隐藏
bool m_isWinHide; // 窗口是否隐藏
...........
}
///dlg.cpp
.....
4000
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)
ON_MESSAGE(WM_MOUSELEAVE,OnMouseLeave)
END_MESSAGE_MAP()
.......
LRESULT CDlg::OnMouseLeave(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
if(m_isAutoHide)
{
CPoint tPoint;
GetCursorPos(&tPoint);
CRect tRect;
GetWindowRect(&tRect);
if(!(tRect.PtInRect(tPoint)))
{
m_isWinHide=true;
tRect.top= tRect.top - tRect.bottom +5;
tRect.bottom= 5;
MoveWindow(tRect);
::SetWindowPos(
::GetDesktopWindow()
,HWND_TOPMOST,tRect.left,tRect.top
,tRect.Width(),tRect.Height ()
,SWP_SHOWWINDOW);
}
}
return TRUE;
}
void CDlg::OnMouseMove(UINT nFlags, CPoint point)
{
if(m_isWinHide)
{
CRect tRect;
GetWindowRect(&tRect);
tRect.bottom+= (tRect.bottom-tRect.top-5);
tRect.top=0;
MoveWindow(tRect);
m_isWinHide= false;
}
TRACKMOUSEEVENT EventTrack;
EventTrack.cbSize= sizeof(TRACKMOUSEEVENT);
EventTrack.dwFlags= TME_LEAVE;
EventTrack.hwndTrack= this->m_hWnd;
_TrackMouseEvent(&EventTrack);
CDialog::OnMouseMove(nFlags, point);
}
<完成>
相关文章推荐
- 制做像QQ那种自动停靠.自动收缩的窗口.
- VC 仿QQ窗口靠边自动收缩隐藏效果
- VC 仿QQ窗口靠边自动收缩隐藏效果
- VC 仿QQ窗口靠边自动收缩隐藏效果
- 再谈布局控件"WeifenLuo.WinFormsUI.Docking"的使用--如何控制自动停靠窗口的大小
- 布局控件"WeifenLuo.WinFormsUI.Docking"的使用--如何控制自动停靠窗口的大小
- VC 仿QQ窗口靠边自动收缩隐藏效果
- MFC仿QQ窗口靠边自动收缩隐藏效果(附源代码)
- DELPHI字符串处理函数大全(收藏在此方便以后查找使用)
- VC 仿QQ窗口靠边自动收缩隐藏效果
- C#中使用WeiFenLuo.WinFormsUI.Docking.dll实现窗口停靠效果
- Visual C++设计超强仿QQ自动伸缩窗口
- springMVC 一些资料(方便以后使用)
- Duilib 实现右下角弹出像QQ新闻窗口,3秒后自动关闭(一)
- winform里面当使用回车时,自动连接到某个按钮——登陆的窗口常用到
- QQ“停靠在桌面边缘时自动隐藏”功能
- 打开网页一段时间如何自动弹出QQ对话邀请窗口?
- mongodb 操作类 好东西收藏起来
- 网上找的压缩文件夹代码,方便以后使用
- 存下十万(100000)以内的所有素数,方便以后打表或者哈希使用,另附筛法