Solved

DragDrop files into a ListBox

Posted on 2003-11-04
6
651 Views
Last Modified: 2007-12-19
I have created a simple Dialog Application with a ListBox

m_dwgList.DragAcceptFiles(TRUE);
allows the drag/drop cursor to work correctly
but now how do I capture the droped file name.

The onyl examples I have found drop into a SID window not a ListBox
0
Comment
Question by:MCofer
  • 3
  • 3
6 Comments
 
LVL 4

Expert Comment

by:YuriPutivsky
ID: 9680969
Use COleDropTarget class
to register your target window and catch OnDrop event like:

class YourClass;
class YourDropTarget : public  COleDropTarget
{
protected:
    virtual BOOL OnDrop(CWnd* pWnd, ...................) { return ((YourClass*)pWnd)->OnDropProcess(.....); }
}

class YourClass : public CWnd
{
friend class YourDropTarget;
private:
    BOOL OnDropProcess(....);
};

Register target OnCreate event and Revoke OnDestroy events

int YourClass::OnCreate(...)
{
    _target.Register(this);
}

void YourClass::OnDestroy(...)
{
    _target.Revoke(this);
}
0
 

Author Comment

by:MCofer
ID: 9681083
I'll give it a try
I am basicly a C programmer and may need a little more detailed help.
I'll let you know how it works.

question:
 Will this also work for a Cut & Paste event?
Thanks
0
 
LVL 4

Expert Comment

by:YuriPutivsky
ID: 9681143
For Cut/Paste you have to use another approach...
0
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.

 
LVL 4

Accepted Solution

by:
YuriPutivsky earned 250 total points
ID: 9681331
I forgot to add YourDropTarget class member
class YourClass : public CWnd
{
friend class YourDropTarget;
private:
    BOOL OnDropProcess(....);
   YourDropTarget _target;
};

0
 

Author Comment

by:MCofer
ID: 9681763
I had already been trying something  simular
but get the error
error C2504: 'COleDropTarget' : base class undefined
trying to create the class.
did I need to include automation when I created the project?
Can i now just add an Include file or how do I implement COle
0
 

Author Comment

by:MCofer
ID: 9682281
#include <afxole.h>

Fixed my initial problem
I'm working now on creating the class
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

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

929 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