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);
}

相关文章:

  • 2021-09-14
  • 2022-02-06
  • 2022-01-24
  • 2021-07-08
  • 2021-11-01
  • 2021-07-21
  • 2022-12-23
  • 2021-10-17
猜你喜欢
  • 2022-01-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-02
  • 2021-05-19
相关资源
相似解决方案