Solved

Simple Drag and Drop Question

Posted on 1997-10-08
2
263 Views
Last Modified: 2013-11-20
I am attempting to perform simple dragging and dropping in a non-ole application (in fact it is a simple dialog based app).  

I have created a cwnd derived child window, made it a drop target (using coledroptarget), and inserted it into my dialog box.  in my OnLButtonDown message handler inside my dialog box class i create a data source (coledatasource) and immediately call DoDragDrop()- using all default arguments.  It was my understanding that this routine would not return until the mouse button is released to end the drag/drop operation.  Instead, what i see is that DoDragDrop returns immediately with a return value of 0.

Is this implementation of drag/drop completely off base?  The mfc knowledge base article "drag and drop: implementing a drop source" basically tells me that what i did was correct.  Whats going on?

thanks, in advance.
0
Comment
Question by:brickb
2 Comments
 
LVL 8

Accepted Solution

by:
gelbert earned 100 total points
ID: 1307733
COleDataSource::DoDragDrop():
The drag-and-drop operation does not start immediately. It waits until the mouse cursor leaves the rectangle specified by lpRectStartDrag or until a specified number of milliseconds have passed. If lpRectStartDrag is NULL, the size of the rectangle is one pixel. The delay time is specified by the DragDelay value in the [Windows] section of WIN.INI. If this value is not in WIN.INI, the default value of 200 milliseconds is used.

See details in VC++ help for this function.

But I think you do not need OLE support to implement drag and drop. As soon as you detected that user wants to start drag and drop( check in OmMouseMove if left mouse button is down (use some flag which is set TRUE in OnLbuttonDown() and FALSE in OnLButtonUp()) and mouse in moving) then change cusrsor shape to
which ever you want to indicate drag and drop operation by using SetCursor() in OnMouseMove() and setting the same cursor with SetClassLong() if neccessary. When you detect OnLButtonUp in target window then change cursor shape to normal and copy data from source. You can also handle Esc key to let user stop drag and drop operation
0
 

Author Comment

by:brickb
ID: 1307734
thank you gelbert.  your response contained many good points.

it turns out that my problem was that i was not calling AfxOleInit() in my InitInstance().


Bob Brickhouse
Grayson Wireless
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now