C++语言 如QQ般隐藏的窗体
BOOL CBeginDlg::OnInitDialog() { SetTimer(1, 100, NULL); //触发定时器 } void CBeginDlg::OnTimer(UINT_PTR nIDEvent) { // TODO: 在此添加消息处理程序代码和/或调用默认值 //MessageBox(L"hello"); CRect rc; CRect rect; GetWindowRect(&rect); rc.CopyRect(&rect); CPoint pOint; GetCursorPos(&pOint); CString s; s.Format(L"%d,%d", pOint.x, pOint.y); SetWindowTextW(s); if(rect.top<0 && PtInRect(rect, pOint)) //当鼠标在窗体内时 { rect.top = 0; MoveWindow(rect.left, rect.top, rc.Width(), rc.Height()); } else if(rect.top>-3 && rect.top < 3 && !PtInRect(rect, pOint)) //当鼠标在屏幕上边框时 { rect.top = 3-rect.Height(); MoveWindow(rect.left, rect.top, rc.Width(), rc.Height()); } CDialog::OnTimer(nIDEvent); }
学习笔记转摘于:
丝酷网 http://www.pythonschool.com/