I am working on a project that will be for both Mac (Cocoa) and Windows. In one window, I have two listboxes. The user may drag and drop between them (to establish a “link” between a pair of rows, one in each listbox).
I want to give the user feedback as to which row in the destination listbox s/he is over during the drag. In the DragOver event, I calculate which row the mouse is over, save that listindex in a window property (actually two properties, one for each listbox), and then invalidate the listbox. (I’ve also tried refresh with the same result.) In the CellBackgroundPaint event of each listbox, I check to see if the row being painted is the same as the row being dragged over, and if it is, I fill the entire cell with a color using fillRect 0,0,g.width, g.height.
This works as desired on the Mac build, but it seems that the CellBackgroundPaint event never gets fired in response to the invalidate (or refresh, even) call in the DragOver event.
It sounds like your implementation is very similar to mine. I’ve duplicated my problem on both Windows Vista and Windows 8. I can’t figure out what I’m doing wrong, especially since it works as it should on the Mac.
I know that the “invalidate” (or “refresh”) call is being made from within the “DragOver” event handler, but if i put a break point in the “CallBackgroundPaint” handler, it does not get hit so long as I am dragging.
I’ve found the problem, though I don’t know why this is the case exactly. While my finding that in a Windows build, CellBackgroundPaint doesn’t fire during the drag in response to a call to invalidate or refresh, it turns out that it WILL fire in response to a call to invalidateCell for the cell in question (and for the previously highlighted cell, if any).
Thanks for your confirmation that you have it working, Karen; it made me dig further. Out of curiosity, do you use invalidate or invalidateCell in your code?