Here is one that was driving me nuts for over a day.....
I made some additions to the wfxPoint class so that it could automatically convert the point from one window coordinate to another (the most common being from screen coordinates to control client coordinates). Easiest way to do that is with MapWindowPoints. So I built that into the class. Thinking everything was okay, I moved on. A few days later I was working on the TreeView.GetNodeAt function and then used wfxPoint during the TreeView's OnMouseDown event handler to do a test. Everything crashed. Immediate GPF when I clicke don a treeview node (granted, it happened more quickly on 32-bit than it did on 64-bit compiled exe's). Where in the world did I go wrong? I thought that maybe it was related to code that I had written to handle SelectedNode for the TreeView but eventually I was able to track it down to the wfxPoint class and specifically the call to wfxPoint.Convert. I thought that my conversion was somehow screwing up the incoming e.pt (from EventArgs) that was assigned to the wfxPoint class and then when OnMouseDown exited it was causing a crash because the point was corrupted in memory. Well, that was somewhat correct.
Here is the code. Can you immediately spot the problem? I must have stared at it for hours thinking that the point address was the problem.
function wfxPoint.Convert( byval hWndFrom as HWND, byval hWndTo as HWND ) as Long
MapWindowPoints( hWndFrom, hWndTo, cast(point ptr, @_pt), 2)
function = 0
end function
function wfxPoint.Convert( byval hWndTo as HWND ) as Long
this.Convert( HWND_DESKTOP, hWndTo )
function = 0
end function
See it? Well, when I eventually did realize my mistake I think I actually cursed out loud and scolded myself for being so stupid. Funny though how something so simple crashed my whole program so easily.
(Jose, I forbid you from answering this question first!) LOL :-)