c++ - 使用 MapWindowPoints 时堆栈损坏

标签 c++ visual-studio-2010 visual-c++ stack

在尝试测试此代码时遇到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;}
}  

你能告诉我,这是怎么回事吗?

最佳答案

是的,应该就是这个

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

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

关于c++ - 使用 MapWindowPoints 时堆栈损坏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15799205/

相关文章:

c++ - ld 返回 1 个错误退出状态 C++

c++ - Valgrind 在为字符串赋值时报告内存泄漏

c# - 使用正则表达式在 Visual Studio 搜索框中搜索电子邮件地址

c# - Intellisense 窗口有输入字段,不占用空间

vb.net - 在批处理文件中使用 Visual Basic 中的字符串

winapi - BitBlt 无法正确捕获标题栏

c++ - 如何避免重复使用 "indices trick"?

c++ - undefined symbol -在centos 7中使用log4cxx

c# - 如何通过 COM 创建从 C#/.NET 到 C++ 的回调?

visual-c++ - 如何使用mupdf从pdf中提取文本?