Solved

DragDrop files into a ListBox

Posted on 2003-11-04
6
657 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
Industry Leaders: 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!

 
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

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
How do i run a c++ file? 15 51
find Speed using GPS latitude & longitude 4 83
Gaming Software 1 28
Finding Divisors 5 35
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

763 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