I'm using windows API to create an application with a window only, so everything inside this window is drawn using Direct2D.
Now I want to drop some files in specific parts of my window's client area, and I'm handling the message WM_DROPFILES
. No problem here, when the files are dropped in those specific areas, I can treat them correctly and everything is working properly. BTW, my window is DragAcceptFiles(hWnd, true)
, it always accepts drag/drops.
I want the mouse cursor to be different depending on the area of the window the mouse is in. In the areas that I don't treat the drop, I want the cursor to be the invalid icon, and for the areas of the window that I do handle the drops, I want the correct drop icon.
The first thing I noticed is that no message is generated when files are being dragged into the window, and for this reason I added a mouse hook (WH_MOUSE_LL
using SetWindowsHookEx
). When the hook is processed, I only look at the WM_MOUSEMOVE
message, so I can change the cursor according to the area the mouse is in.
The problem is that the SetCursor
does nothing, if my windows is configured to accept drag files, the cursor is always the drag/drop cursor, no matter how many times I call SetCursor
.
It seems impossible to change the cursor this way, but is there any other way of doing what I'm trying to achieve?
IDropTarget
interface, and then set the cursor usingSetCursor()
within theDragOver
method.IDropTarget::DragEnter()
andIDropTarget::DragOver()
implementations, it needs to set thepdwEffect
output parameter to an appropriateDROPEFFECT
value. That value then gets passed back to the drop source, which then displays visual feedback to the user (like changing the cursor) in itsIDropSource::GiveFeedback()
implementation.IDropTarget
to be invoked without user interaction (ie, programably from another app), which is why the source, not the target, decides whether or not to display UI updates to the user. The target does not know (or care) why it is being invoked, only that it is being given some data and asked whether it will accept or reject that data, nothing more.IDropTarget
andIDropSource
in practice, I was just going based on my Win32 knowledge and the documentation. Would you care to post that as an answer?