0

尝试Stack around the variable "rc" was corrupted测试此代码时出错(使用返回的坐标将鼠标移动到那里)
请参见下面的代码:

int TestPluginAPI::getmidX()
{
//RECT rect; 
HWND hWnd;
hWnd = getBrowserHwnd();
RECT rc;
if(GetClientRect(hWnd, &rc))  // get client coords 
{
MapWindowPoints(hWnd, NULL, reinterpret_cast<POINT*>(&rc.left), 2); // convert top-left x
MapWindowPoints(hWnd, NULL, reinterpret_cast<POINT*>(&rc.right), 2); // convert bottom-right x
MapWindowPoints(hWnd, NULL, reinterpret_cast<POINT*>(&rc.top), 2); // convert top-left y
MapWindowPoints(hWnd, NULL, reinterpret_cast<POINT*>(&rc.bottom), 2); // convert bottom-right y
return rc.left;
}
else {return 0;}
}  

你能告诉我,有什么问题吗?

4

1 回答 1

3

是的,应该就是这个

if(GetClientRect(hWnd, &rc))  // get client coords 
{
    MapWindowPoints(hWnd, NULL, reinterpret_cast<POINT*>(&rc), 2);
    return rc.left;
}

矩形是两个点(左上角和右下角)。所以你只需要调用一次 MapWindowPoints,计数为 2。

于 2013-04-03T22:20:21.510 回答