http://www.cnblogs.com/stg609/articles/1226222.htmlvoid CroundDlg::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default CDialogEx::OnLButtonDown(nFlags, point); PostMessage(WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(point.x, point.y)); if(m_flag) { m_funcdlg.ShowWindow(SW_HIDE); m_flag = false; } } WM_MOUSELEAVE 消息不同于其他消息,只有调用函数TrackMouseEvent追踪当前鼠标状态,才会响应它,并且调用一次只响应一次,所以每次想响应WM_MOUSELEAVE消息,必须调用TrackMouseEvent函数,故此函数一般放在OnMouseMove函数中。示例如下: void CroundDlg::OnMouseMove(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default if(m_flag) { ::GetWindowRect(this->m_hWnd,&m_Clientrc); //屏幕坐标 ::GetWindowRect(m_funcdlg.m_hWnd, &m_Toolrc); //客户区坐标 int ScreenHeight = GetSystemMetrics(SM_CYSCREEN); //获取屏幕高度 //判断图形界面在上面还是下面显示 if(ScreenHeight - m_Clientrc.top > 2*m_Toolrc.Height()) { m_funcdlg.MoveWindow(m_Clientrc.left-m_Toolrc.Width(),m_Clientrc.top+40, m_Toolrc.Width(), m_Toolrc.Height()); } else { m_funcdlg.MoveWindow(m_Clientrc.left-m_Toolrc.Width(),m_Clientrc.top-m_Toolrc.Height()+20, m_Toolrc.Width(), m_Toolrc.Height()); } m_funcdlg.ShowWindow(SW_SHOW); if(m_bMouseTrack) { TRACKMOUSEEVENT csTME; csTME.cbSize = sizeof(csTME); csTME.dwFlags = TME_LEAVE; csTME.hwndTrack = this->m_hWnd; csTME.dwHoverTime = 1000; ::_TrackMouseEvent(&csTME); m_bMouseTrack = TRUE; } //m_flag = true; void CroundDlg::OnMouseLeave() //鼠标离开响应函数 { // TODO: Add your message handler code here and/or call default if(g_dragflag) { m_funcdlg.ShowWindow(SW_HIDE); m_bMouseTrack = TRUE; m_flag = TRUE; //g_dragflag = true; } void CroundDlg::OnDropFiles(HDROP hDropInfo) //鼠标响应文件拖拽函数 { // TODO: Add your message handler code here and/or call default ::GetWindowRect(this->m_hWnd,&m_Clientrc); //屏幕坐标 ::GetWindowRect(m_funcdlg.m_hWnd, &m_Toolrc); //客户区坐标 int ScreenHeight = GetSystemMetrics(SM_CYSCREEN); //获取屏幕高度 //判断图形界面在上面还是下面显示 if(ScreenHeight - m_Clientrc.top > 2*m_Toolrc.Height()) { m_funcdlg.MoveWindow(m_Clientrc.left-m_Toolrc.Width(),m_Clientrc.top+40, m_Toolrc.Width(), m_Toolrc.Height()); } else { //this->ShowWindow(SW_HIDE); m_funcdlg.MoveWindow(m_Clientrc.left-m_Toolrc.Width(),m_Clientrc.top-m_Toolrc.Height()+20, m_Toolrc.Width(), m_Toolrc.Height()); } this->ShowWindow(SW_HIDE); m_funcdlg.ShowWindow(SW_SHOW); TCHAR m_file[260]={0}; int numfiles; numfiles = DragQueryFile(hDropInfo, 0xFFFFFFFF,NULL,0); m_mapFiles.clear(); for(int i=0; i<numfiles; i++) { if(0 == DragQueryFile(hDropInfo, i, m_file, 260)) continue; m_mapFiles[i] = m_file; } CString tmp; tmp.Format("%s\n%s", m_mapFiles[0], m_mapFiles[1]); //MessageBox(tmp); g_dragflag = false; CDialogEx::OnDropFiles(hDropInfo); } void CroundDlg::OnLButtonDown(UINT nFlags, CPoint point) //给标题发送wm_nclbuttondown消息,使其能够移动 { // TODO: Add your message handler code here and/or call default CDialogEx::OnLButtonDown(nFlags, point); PostMessage(WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(point.x, point.y)); if(m_flag) { m_funcdlg.ShowWindow(SW_HIDE); m_flag = false; } }
WM_MOUSELEAVE 消息
最新推荐文章于 2016-07-21 15:36:31 发布