views:

30

answers:

2

Hi,

I've a quite difficult problem to explain but I will try my best. I've made a custom drag-drop implementation to a win32 GUI based application. Due to limitations of the program I can't use the proper OLE drag-drop mechanism. Its okey, I made my own with mouse key tracking and it works so so. The only problem I can't solve now is the bloody invalid (slashed circle) - IDC_NO cursor.

My window thinks it is undroppable and changes the cursor to invalid when something is about to drop. I tried everything to change it but it insists to stay there.

case WM_SETCURSOR:
{
    //SetSystemCursor(CopyCursor(LoadCursor(NULL, IDC_CROSS)), 32648);
    //DestroyCursor();
    SetCursor(LoadCursor(NULL, IDC_CROSS));
    SetWindowLong(hwnd, DWL_MSGRESULT, TRUE);
    return TRUE;
}
break;

I even tried, to change icon outside the message switch which runs in every call to the callback function. It worked a little but not OK. Its like I'm setting it to IDC_CROSS cursor but it is returning back to IDC_NO.

How can I get rid-off this invalid cursor? I want to set it to IDC_CROSS.

Or how can I implement a Drag-drop without using OLE or MFC classes to make my application dropable and not showing that invalid cursor.

Quite complicated but thank you for your time, even for reading my question ;)

+1  A: 

You're on the wrong track with this. The cursor shape is not controlled by WM_SETCURSOR anymore when a D+D is in progress. COM takes over and alters the shape when a window give the 'okay to drop' feedback. Which is probably what's missing from your code.

You cannot bypass 'OLE' or the MFC wrappers that make it easy, the source of the drag will use it. Lookup IDropTarget::DragEnter to get that right. Using a class wrapper is certainly the best approach, it isn't that easy to get it right on your own.

Hans Passant
Ok. Thank you. Now I know I was trying the impossible ;)
tesla
+1  A: 

Are you registering your window to accept dragged files with the DragAcceptFiles function? (http://msdn.microsoft.com/en-us/library/bb776406%28VS.85%29.aspx) It's useful for getting very basic drag-drop functionality without getting into OLE, but doesn't provide as much versatility, because you only get the WM_DROPFILES message after the mouse button is released.

brian
Yes, I tried accepting drop files but that works for file droppings only. Problem continues if it is a text drop.
tesla