m_isSetTimer = FALSE;m_hsFinished = TRUE; m_hiding = FALSE;m_oldWndHeight = MINCY; m_taskBarHeight = 30; m_edgeHeight = 0; m_edgeWidth=0; m_hideMode = HM_NONE; |
int CQQHideWndDlg::OnCreate(LPCREATESTRUCT lpCreateStruct) //获得任务栏高度
CWnd* p; p = this->FindWindow("Shell_TrayWnd",NULL); if(p != NULL) { CRect tRect; p->GetWindowRect(tRect); m_taskBarHeight = tRect.Height(); } //修改风格使得他不在任务栏显示
ModifyStyleEx(WS_EX_APPWINDOW, WS_EX_TOOLWINDOW); //去掉关闭按键(如果想画3个按键的话) //ModifyStyle(WS_SYSMENU,NULL); //获得边缘高度和宽度
m_edgeHeight = GetSystemMetrics(SM_CYEDGE); m_edgeWidth = GetSystemMetrics(SM_CXFRAME); return 0; } |
代码二
UINT CQQHideWndDlg::OnNcHitTest(CPoint point) |
void CQQHideWndDlg::OnTimer(UINT nIDEvent) CRect tRect;
//获取此时窗口大小 GetWindowRect(tRect); //膨胀tRect,以达到鼠标离开窗口边沿一定距离才触发事件 tRect.InflateRect(INFALTE,INFALTE); if(!tRect.PtInRect(curPos)) //如果鼠标离开了这个区域
{ KillTimer(1); //关闭检测鼠标Timer m_isSetTimer = FALSE; GetDlgItem(IDC_TIMER)->SetWindowText("Timer Off"); m_hsFinished = FALSE;
m_hiding = TRUE; SetTimer(2,HS_ELAPSE,NULL); //开启收缩过程 } } if(nIDEvent == 2) { if(m_hsFinished) //如果收缩或显示过程完毕则关闭Timer KillTimer(2); else m_hiding ? DoHide() : DoShow(); } CDialog::OnTimer(nIDEvent); } |