高手帮忙!!!!!!!!!!!!1 怎样制作类似QQ自动隐藏的窗口。提供一些提示也行。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://topic.csdn.net/t/20050409/17/3922759.html 转载的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) 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://www.vckbase.com/english/code/misc/TrackMouseEvent.shtml.htm 如何压缩16位bmp成jpeg格式 在编译的时候不小心将LINK里的project option给删除了。怎么办? 怎样获得editbox的值?谢谢 MSComm开发程序移植到Windows2000的乱码问题 TreeView中所绑定的TreeCtrl如何接收WM_NOTIFY消息? 版主大人请进 启动其他程序(很急) 二维数组初始化时出错 小问题一个,对中级以上不是问题!!!!! 一个很弱的问题 CSocket类是不是不能用在DLL中啊? 如何清除Temporary Internet Files中下载的文件?
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)
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); }