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

x
?
Solved

DragDrop files into a ListBox

Posted on 2003-11-04
6
Medium Priority
?
666 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
[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
  • 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 4

Accepted Solution

by:
YuriPutivsky earned 1000 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

Independent Software Vendors: 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

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
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 viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

722 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