刘华世的官方博客

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);
}
posted @ 2012-11-15 10:41  pythonschool  阅读(274)  评论(0编辑  收藏  举报
刘华世的官方博客