海信家电”换帅 “ 高玉玲接替代慧忠出任新任董事长
2024-11-22
protected:
//修正移动时窗口的大小 void FixMoving(UINT fwSide, LPRECT pRect); //从收缩状态显示窗口 void DoShow(); //从显示状态收缩窗口 void DoHide(); //重载函数,只是为了方便调用,实际调用CWnd的SetWindowPos(…) BOOL SetWindowPos(const CWnd* pWndInsertAfter,LPCRECT pCRect, UINT nFlags = SWP_SHOWWINDOW); |
private::BOOL m_isSizeChanged;//窗口大小是否改变了
BOOL m_isSetTimer;//是否设置了检测鼠标的Timer INTm_oldWndHeight;//旧的窗口宽度INTm_taskBarHeight;//任务栏高度INTm_edgeHeight;//边缘高度 INTm_edgeWidth;//边缘宽度 INTm_hideMode;//隐藏模式 BOOL m_hsFinished;//隐藏或显示过程是否完成 BOOL m_hiding;//该参数只有在!m_hsFinished才有效 //真:正在隐藏,假:正在显示 |
WM_ NCHITTEST
WM_MOVING WM_CREATE WM_TIMER |
//收缩模式#define HM_NONE0//不收缩
#define HM_TOP1//向上收缩 #define HM_BOTTOM2//向下收缩 #define HM_LEFT3//向左收缩 #define HM_RIGHT4//向右收缩 #define CM_ELAPSE200 //检测鼠标是否离开窗口的时间间隔 #define HS_ELAPSE5//伸缩过程每步的时间间隔 #define HS_STEPS10//伸缩过程分成多少步完成 #define INTERVAL20//触发粘附时鼠标与屏幕边界的最小间隔,单位为象素 #define INFALTE10//触发收缩时鼠标与窗口边界的最小间隔,单位为象素 |
m_isSizeChanged = FALSE;
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)
{ if (CDialog::OnCreate(lpCreateStruct) == -1) return -1; // TODO: Add your specialized creation code here
//获得任务栏高度
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)
{ // TODO: Add your message handler code here and/or call default CString str; str.Format("Mouse (%d,%d)",point.x,point.y); GetDlgItem(IDC_CURSOR)->SetWindowText(str); if(m_hideMode != HM_NONE && !m_isSetTimer && //防止鼠标超出屏幕右边时向右边收缩造成闪烁 point.x < GetSystemMetrics(SM_CXSCREEN) + INFALTE) { //鼠标进入时,如果是从收缩状态到显示状态则开启Timer SetTimer(1,CM_ELAPSE,NULL); m_isSetTimer = TRUE; m_hsFinished = FALSE;
m_hiding = FALSE; SetTimer(2,HS_ELAPSE,NULL); //开启显示过程 } return CDialog::OnNcHitTest(point); } |
void CQQHideWndDlg::OnTimer(UINT nIDEvent)
{ // TODO: Add your message handler code here and/or call default if(nIDEvent == 1 ) { POINT curPos; GetCursorPos(&curPos); CString str;
str.Format("Timer On(%d,%d)",curPos.x,curPos.y); GetDlgItem(IDC_TIMER)->SetWindowText(str); 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); } |
评论 {{userinfo.comments}}
{{child.content}}
{{question.question}}
提交