Max*_*ari 5 c++ browser winapi plugins
如何获取窗口客户区相对于屏幕的坐标?
我想过用GetClientRect和ClientToScreen.另外,在浏览器窗口中是什么ClientRect?只HTML显示包含文档的矩形,或者它包含浏览器栏和弹出菜单,可能会缩小HTMLdoc的维度?
我试过这个:
HWND hWnd;
RECT rc;
if (GetClientRect(hWnd, &rc)) // get client coords
{
MapWindowPoints(hWnd, NULL, reinterpret_cast<POINT*>(&rc), 2); // converts rect rc points
return rc.top;
}
Run Code Online (Sandbox Code Playgroud)
但令人遗憾的是,浏览器的客户端矩形包括所有弹出的浏览器菜单和条形图,因此不能用于检测浏览器HTML文档空间的准确坐标.如果有人得到如何做的建议,将很乐意尝试.
Jon*_*ter 11
是的,您可以使用以下ClientToScreen功能执行此操作:
RECT rc;
GetClientRect(hWnd, &rc); // get client coords
ClientToScreen(hWnd, reinterpret_cast<POINT*>(&rc.left)); // convert top-left
ClientToScreen(hWnd, reinterpret_cast<POINT*>(&rc.right)); // convert bottom-right
Run Code Online (Sandbox Code Playgroud)
浏览器中的"客户端"矩形取决于浏览器实现.您可以使用Spy ++自行发现.