Solved

Simple Drag and Drop Question

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
iSeries FTP Exit Program 8 163
sum13 challenge 24 134
How to convert MFC::CString to UTF8 wchar_t* 10 372
Authenticate using sesu from script 7 108
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

735 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