Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Simple Drag and Drop Question

Posted on 1997-10-08
2
Medium Priority
?
270 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Accepted Solution

by:
gelbert earned 300 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

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

688 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