ahmd0
ahmd0

Reputation: 17293

Receive notifications of a pending drag-and-drop operation over my window in C++

I have an MFC dialog window with controls in it that support drag-and-drop feature. Those controls are registered to receive drag-and-drops, and that part works fine.

My question is about my main MFC dialog window. Is it possible to receive notifications in it when drag-and-dropped "object" is being dragged over that window, and at what coordinate is it over my window?

PS. I need this functionality to "unfurl" certain controls in the main window while drag-and-drop is in progress so that the user could then drop "objects" into them.

Upvotes: 1

Views: 249

Answers (1)

cha
cha

Reputation: 10411

Read about COleDropTarget class. Basically, you create a member variable inside your main window, then call COleDropTarget::Register method to register the window. Then you need to implement OnDragEnter(), OnDragOver(), OnDragLeave(), OnDrop() in your window.

See this nice codeproject article as an example (skip the section about DragAcceptFiles, I have a feeling that you do need to support files, otherwise, it is even easier.)

Upvotes: 2

Related Questions