Warning: file_get_contents(https://whois.pconline.com.cn/jsLabel.jsp?ip=127.0.0.1) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 503 Service Temporarily Unavailable in D:\wwwroot\huidong\wwwroot\function.inc.php on line 884
Win32 锁定鼠标在窗口内部(利用 ClipCursor) - huidong

huidong

首页 | 会员登录 | 关于争取 2022 寒假做出汇东网 Ver3.0.0 !
搜索文章


ClipCursor 可以将鼠标锁定在某个区域内


/**
 * @brief 锁定鼠标在窗口内
 * @param hwnd : 窗口句柄
*/
void ClipCursor(HWND hwnd)
{
    RECT rt;
    POINT lt, rb;
    GetClientRect(hwnd, &rt);
    lt.x = rt.left;
    lt.y = rt.top;
    rb.x = rt.right;
    rb.y = rt.bottom;
    ClientToScreen(hwnd, &lt);
    ClientToScreen(hwnd, &rb);
    rt.left = lt.x;
    rt.top = lt.y;
    rt.right = rb.x;
    rt.bottom = rb.y;
    ClipCursor(&rt);
}


转自 https://blog.csdn.net/h549570564/article/details/44134315

实测可用




返回首页


Copyright (C) 2018-2024 huidong