Solved

Simple Drag and Drop Question

Posted on 1997-10-08
2
264 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
unable to delete all specified values regedit 38 273
either24  challenge 19 90
ShiftLeft challenge 21 76
child constructor and parent constructor, overriding and overloading 6 77
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

914 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

20 Experts available now in Live!

Get 1:1 Help Now