HEAP CORRUPTION DETECTED!
-
hallo, i have the following piece of code , when i try to delete the lpKeyPoint i get HEAP CORRUPTION DETECTED! LPPOINT lpKeyPoint; lpKeyPoint = (LPPOINT)new LPPOINT(); GetCaretPos((LPPOINT)lpKeyPoint); if(lpKeyPoint) { delete lpKeyPoint; lpKeyPoint = NULL; } How can i solve this problem? Thanks.
susanne1 wrote:
lpKeyPoint = (LPPOINT)new LPPOINT()
That should be:
lpKeyPoint = new POINT();
:)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
susanne1 wrote:
lpKeyPoint = (LPPOINT)new LPPOINT()
That should be:
lpKeyPoint = new POINT();
:)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]thanks it worsk,but when i move the curosor up i get a worng value of y: CPoint* ptrKeyPoint = new CPoint(); int nCursorLine = 0; if((pMsg->message == WM_KEYDOWN)||(pMsg->message == WM_LBUTTONDOWN)) { if((pMsg->wParam == VK_RETURN) || (pMsg->wParam == VK_UP)||(pMsg->wParam == VK_DOWN) || (pMsg->message == WM_LBUTTONUP)) { GetCaretPos((LPPOINT)ptrKeyPoint); nCursorLine = ptrKeyPoint->y; } if(ptrKeyPoint) { delete ptrKeyPoint; ptrKeyPoint = NULL; } }
-
thanks it worsk,but when i move the curosor up i get a worng value of y: CPoint* ptrKeyPoint = new CPoint(); int nCursorLine = 0; if((pMsg->message == WM_KEYDOWN)||(pMsg->message == WM_LBUTTONDOWN)) { if((pMsg->wParam == VK_RETURN) || (pMsg->wParam == VK_UP)||(pMsg->wParam == VK_DOWN) || (pMsg->message == WM_LBUTTONUP)) { GetCaretPos((LPPOINT)ptrKeyPoint); nCursorLine = ptrKeyPoint->y; } if(ptrKeyPoint) { delete ptrKeyPoint; ptrKeyPoint = NULL; } }
susanne1 wrote:
when i move the curosor up i get a worng value of y:
What do you mean (i.e. details please)? :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
susanne1 wrote:
when i move the curosor up i get a worng value of y:
What do you mean (i.e. details please)? :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
susanne1 wrote:
when i press the arrow key up.
I think he can get that - what y value do you get ? 'g'
-
susanne1 wrote:
when i press the arrow key up.
I think he can get that - what y value do you get ? 'g'
Garth J Lancaster wrote:
I think he can get that
Well, it's Monday............. :-D
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
I try again: "How do you know that
y
value is wrong (please provide us details)?" :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
I try again: "How do you know that
y
value is wrong (please provide us details)?" :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
thanks it worsk,but when i move the curosor up i get a worng value of y: CPoint* ptrKeyPoint = new CPoint(); int nCursorLine = 0; if((pMsg->message == WM_KEYDOWN)||(pMsg->message == WM_LBUTTONDOWN)) { if((pMsg->wParam == VK_RETURN) || (pMsg->wParam == VK_UP)||(pMsg->wParam == VK_DOWN) || (pMsg->message == WM_LBUTTONUP)) { GetCaretPos((LPPOINT)ptrKeyPoint); nCursorLine = ptrKeyPoint->y; } if(ptrKeyPoint) { delete ptrKeyPoint; ptrKeyPoint = NULL; } }
Ummmm - just don't use the heap, OK - this should work just as well:
CPoint keyPoint;
int nCursorLine = 0;
if((pMsg->message == WM_KEYDOWN)||(pMsg->message == WM_LBUTTONDOWN))
{
if((pMsg->wParam == VK_RETURN) || (pMsg->wParam == VK_UP)||(pMsg->wParam == VK_DOWN) || (pMsg->message == WM_LBUTTONUP))
{
GetCaretPos(&keyPoint);
nCursorLine = keyPoint.y;
}See what I've done there - I've declared and defined the CPoint item as a local, so it's on the stack. Then you don't need to worry about deallocation or anything. Much simpler.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
-
Ummmm - just don't use the heap, OK - this should work just as well:
CPoint keyPoint;
int nCursorLine = 0;
if((pMsg->message == WM_KEYDOWN)||(pMsg->message == WM_LBUTTONDOWN))
{
if((pMsg->wParam == VK_RETURN) || (pMsg->wParam == VK_UP)||(pMsg->wParam == VK_DOWN) || (pMsg->message == WM_LBUTTONUP))
{
GetCaretPos(&keyPoint);
nCursorLine = keyPoint.y;
}See what I've done there - I've declared and defined the CPoint item as a local, so it's on the stack. Then you don't need to worry about deallocation or anything. Much simpler.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
But corrupting the heap is much more fun. ;)
It is a crappy thing, but it's life -^ Carlo Pallini