了Stack around the variable "rc" was corrupted
錯誤,試圖測試此代碼時損壞的堆棧(使用返回座標那裏移動鼠標)
請參閱下面的代碼:同時使用MapWindowPoints
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;}
}
你能告訴我,什麼是錯的?
值得在使用它們之前閱讀這些函數的文檔:http://msdn.microsoft.com/en-us/library/windows/desktop/ dd145046(v = vs.85).aspx – LihO 2013-04-03 22:22:14
當你傳遞&rc.bottom並且說有兩點時,你的堆棧會被破壞。只有一個。向微軟購買一支雪茄,讓你遠離深沉的麻煩。 – 2013-04-03 22:26:14
爲了好奇,你的意思是什麼樣的可怕的麻煩? – 2013-04-03 22:42:18